<s> import mock <EOL> from django . test import TestCase <EOL> from django . contrib . auth . models import User <EOL> from django . core . urlresolvers import reverse <EOL> from django . conf import settings as djsettings <EOL> from django . utils . encoding import smart_text <EOL> try : <EOL> from importlib import import_module <EOL> except ImportError : <EOL> from django . utils . importlib import import_module <EOL> from backward import settings <EOL> from backward . helpers import engine <EOL> class BasicTests ( TestCase ) : <EOL> def setUp ( self ) : <EOL> settings . SESSION_ENGINE = '<STR_LIT>' <EOL> engine = import_module ( '<STR_LIT>' ) <EOL> store = engine . SessionStore ( ) <EOL> store . save ( ) <EOL> self . session = store <EOL> self . client . cookies [ djsettings . SESSION_COOKIE_NAME ] = store . session_key <EOL> def test_ajax_simple ( self ) : <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) , HTTP_X_REQUESTED_WITH = '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertNotIn ( '<STR_LIT>' , self . client . session ) <EOL> def test_simple ( self ) : <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( self . client . session [ '<STR_LIT>' ] , u'<STR_LIT>' ) <EOL> def test_ignorable ( self ) : <EOL> with mock . patch . object ( settings , '<STR_LIT>' , ( <EOL> '<STR_LIT>' , <EOL> ) ) : <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertNotIn ( '<STR_LIT>' , self . client . session ) <EOL> with mock . patch . object ( settings , '<STR_LIT>' , ( <EOL> '<STR_LIT>' , <EOL> ) ) : <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertNotIn ( '<STR_LIT>' , self . client . session ) <EOL> def test_login_redirect ( self ) : <EOL> with mock . patch . object ( settings , '<STR_LIT>' , ( <EOL> '<STR_LIT>' , <EOL> ) ) : <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> self . assertEqual ( self . client . session [ '<STR_LIT>' ] , u'<STR_LIT>' ) <EOL> User . objects . create_user ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> response = self . client . post ( reverse ( '<STR_LIT>' ) , data = { <EOL> '<STR_LIT:username>' : '<STR_LIT>' , <EOL> '<STR_LIT:password>' : '<STR_LIT>' <EOL> } ) <EOL> self . assertRedirects ( response , <EOL> '<STR_LIT>' , <EOL> status_code = <NUM_LIT> , <EOL> target_status_code = <NUM_LIT> ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertRedirects ( response , <EOL> '<STR_LIT>' , <EOL> status_code = <NUM_LIT> , <EOL> target_status_code = <NUM_LIT:200> ) <EOL> def test_action_simple ( self ) : <EOL> with mock . patch . object ( settings , '<STR_LIT>' , ( <EOL> '<STR_LIT>' , <EOL> ) ) : <EOL> parameters = { <EOL> smart_text ( '<STR_LIT:key>' ) : '<STR_LIT:value>' <EOL> } <EOL> response = self . client . post ( reverse ( '<STR_LIT>' ) , data = parameters ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> User . objects . create_user ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> data = engine . get_next_action ( self . client ) <EOL> assert '<STR_LIT>' in data <EOL> assert '<STR_LIT:POST>' in data [ '<STR_LIT>' ] <EOL> response = self . client . post ( reverse ( '<STR_LIT>' ) , data = { <EOL> '<STR_LIT:username>' : '<STR_LIT>' , <EOL> '<STR_LIT:password>' : '<STR_LIT>' <EOL> } ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> assert '<STR_LIT>' in self . client . session <EOL> assert self . client . session [ '<STR_LIT>' ] is True </s>
