<s> from datetime import date <EOL> from django . test import RequestFactory <EOL> from django . test . testcases import TestCase <EOL> from test_app . models import TestModel <EOL> class TestEditViews ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . factory = RequestFactory ( ) <EOL> self . m = TestModel ( ) <EOL> self . m . date = date ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> self . id = self . m . save ( ) <EOL> self . n = TestModel ( ) <EOL> self . n . date = date . today ( ) <EOL> self . n . save ( ) <EOL> def test_create_view ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' , { } , <EOL> HTTP_X_REQUESTED_WITH = "<STR_LIT>" ) <EOL> self . assertEqual ( [ "<STR_LIT>" , ] , <EOL> response . template_name ) <EOL> def test_create_view_success ( self ) : <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:date>' : date ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT> ) } , <EOL> follow = True , <EOL> HTTP_X_REQUESTED_WITH = "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:200> , response . status_code ) <EOL> self . assertTrue ( '<STR_LIT>' in response . template_name ) <EOL> def test_create_view_failure ( self ) : <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:date>' : <NUM_LIT:1> } , <EOL> follow = True , <EOL> HTTP_X_REQUESTED_WITH = "<STR_LIT>" ) <EOL> self . assertTrue ( '<STR_LIT>' in response . template_name ) <EOL> def test_update_view ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' , <EOL> { } , <EOL> HTTP_X_REQUESTED_WITH = "<STR_LIT>" ) <EOL> self . assertEqual ( [ "<STR_LIT>" , ] , <EOL> response . template_name ) <EOL> def test_update_success ( self ) : <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:date>' : date ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT> ) } , <EOL> follow = True , <EOL> HTTP_X_REQUESTED_WITH = "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:200> , response . status_code ) <EOL> self . assertTrue ( '<STR_LIT>' in response . template_name ) <EOL> def test_update_view_failure ( self ) : <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { '<STR_LIT:date>' : <NUM_LIT:1> } , <EOL> follow = True , <EOL> HTTP_X_REQUESTED_WITH = "<STR_LIT>" ) <EOL> self . assertTrue ( '<STR_LIT>' in response . template_name ) <EOL> def test_delete_view ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' , <EOL> { } , <EOL> HTTP_X_REQUESTED_WITH = "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT>" in <EOL> response . template_name ) <EOL> def test_delete_view ( self ) : <EOL> response = self . client . post ( '<STR_LIT>' , <EOL> { } , <EOL> HTTP_X_REQUESTED_WITH = "<STR_LIT>" , <EOL> follow = True ) <EOL> self . assertTrue ( "<STR_LIT>" in <EOL> response . template_name ) </s>
