<s> from django . test import TestCase <EOL> from django . utils import timezone <EOL> from polls . models import Poll <EOL> from polls . models import Choice <EOL> class PollTestCase ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . poll = Poll . objects . create ( <EOL> question = "<STR_LIT>" , <EOL> pub_date = timezone . now ( ) <EOL> ) <EOL> self . poll . save ( ) <EOL> def test_creation ( self ) : <EOL> p = Poll . objects . create ( <EOL> question = "<STR_LIT>" , <EOL> pub_date = timezone . now ( ) <EOL> ) <EOL> p . save ( ) <EOL> self . assertEqual ( Poll . objects . count ( ) , <NUM_LIT:2> ) <EOL> def test_update ( self ) : <EOL> self . poll . question = "<STR_LIT>" <EOL> self . poll . save ( ) <EOL> p = Poll . objects . get ( ) <EOL> self . assertEqual ( p . question , "<STR_LIT>" ) <EOL> def test_delete ( self ) : <EOL> p = Poll . objects . get ( ) <EOL> p . delete ( ) <EOL> self . assertEqual ( Poll . objects . count ( ) , <NUM_LIT:0> ) <EOL> class ChoiceTestCase ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . poll = Poll . objects . create ( <EOL> question = "<STR_LIT>" , <EOL> pub_date = timezone . now ( ) <EOL> ) <EOL> self . poll . save ( ) <EOL> self . choice = Choice . objects . create ( <EOL> poll = self . poll , <EOL> choice_text = "<STR_LIT>" , <EOL> votes = <NUM_LIT:2> <EOL> ) <EOL> def test_choice_creation ( self ) : <EOL> p = Choice . objects . create ( <EOL> poll = self . poll , <EOL> choice_text = "<STR_LIT>" , <EOL> votes = <NUM_LIT:5> <EOL> ) <EOL> p . save ( ) <EOL> self . assertEqual ( Choice . objects . count ( ) , <NUM_LIT:2> ) <EOL> def test_choice_update ( self ) : <EOL> self . choice . choice_text = "<STR_LIT>" <EOL> self . choice . save ( ) <EOL> p = Choice . objects . get ( ) <EOL> self . assertEqual ( p . choice_text , "<STR_LIT>" ) <EOL> def test_choice_delete ( self ) : <EOL> p = Choice . objects . get ( ) <EOL> p . delete ( ) <EOL> self . assertEqual ( Choice . objects . count ( ) , <NUM_LIT:0> ) </s>
