<s> from __future__ import with_statement <EOL> import os <EOL> from django . test import TestCase <EOL> from django . conf import settings <EOL> from django . contrib . auth . models import User <EOL> import formwizard <EOL> class WizardTests ( object ) : <EOL> urls = '<STR_LIT>' <EOL> def setUp ( self ) : <EOL> self . testuser , created = User . objects . get_or_create ( username = '<STR_LIT>' ) <EOL> self . wizard_step_data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] = self . testuser . pk <EOL> def test_initial_call ( self ) : <EOL> response = self . client . get ( self . wizard_url ) <EOL> wizard = response . context [ '<STR_LIT>' ] <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( wizard [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> self . assertEqual ( wizard [ '<STR_LIT>' ] . step0 , <NUM_LIT:0> ) <EOL> self . assertEqual ( wizard [ '<STR_LIT>' ] . step1 , <NUM_LIT:1> ) <EOL> self . assertEqual ( wizard [ '<STR_LIT>' ] . last , '<STR_LIT>' ) <EOL> self . assertEqual ( wizard [ '<STR_LIT>' ] . prev , None ) <EOL> self . assertEqual ( wizard [ '<STR_LIT>' ] . next , '<STR_LIT>' ) <EOL> self . assertEqual ( wizard [ '<STR_LIT>' ] . count , <NUM_LIT:4> ) <EOL> def test_form_post_error ( self ) : <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_1_data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . errors , <EOL> { '<STR_LIT:name>' : [ u'<STR_LIT>' ] , <EOL> '<STR_LIT:user>' : [ u'<STR_LIT>' ] } ) <EOL> def test_form_post_success ( self ) : <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:0> ] ) <EOL> wizard = response . context [ '<STR_LIT>' ] <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( wizard [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> self . assertEqual ( wizard [ '<STR_LIT>' ] . step0 , <NUM_LIT:1> ) <EOL> self . assertEqual ( wizard [ '<STR_LIT>' ] . prev , '<STR_LIT>' ) <EOL> self . assertEqual ( wizard [ '<STR_LIT>' ] . next , '<STR_LIT>' ) <EOL> def test_form_stepback ( self ) : <EOL> response = self . client . get ( self . wizard_url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> response = self . client . post ( self . wizard_url , { <EOL> '<STR_LIT>' : response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . prev } ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> def test_template_context ( self ) : <EOL> response = self . client . get ( self . wizard_url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> self . assertEqual ( response . context . get ( '<STR_LIT>' , None ) , None ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> self . assertEqual ( response . context . get ( '<STR_LIT>' , None ) , True ) <EOL> def test_form_finish ( self ) : <EOL> response = self . client . get ( self . wizard_url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> post_data = self . wizard_step_data [ <NUM_LIT:1> ] <EOL> post_data [ '<STR_LIT>' ] = open ( __file__ ) <EOL> response = self . client . post ( self . wizard_url , post_data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:2> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:3> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> all_data = response . context [ '<STR_LIT>' ] <EOL> self . assertEqual ( all_data [ <NUM_LIT:1> ] [ '<STR_LIT>' ] . read ( ) , open ( __file__ ) . read ( ) ) <EOL> del all_data [ <NUM_LIT:1> ] [ '<STR_LIT>' ] <EOL> self . assertEqual ( all_data , [ <EOL> { '<STR_LIT:name>' : u'<STR_LIT>' , '<STR_LIT>' : True , '<STR_LIT:user>' : self . testuser } , <EOL> { '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT>' : u'<STR_LIT>' } , <EOL> { '<STR_LIT>' : u'<STR_LIT>' } , <EOL> [ { '<STR_LIT>' : u'<STR_LIT>' } , <EOL> { '<STR_LIT>' : u'<STR_LIT>' } ] ] ) <EOL> def test_cleaned_data ( self ) : <EOL> response = self . client . get ( self . wizard_url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> post_data = self . wizard_step_data [ <NUM_LIT:1> ] <EOL> post_data [ '<STR_LIT>' ] = open ( __file__ ) <EOL> response = self . client . post ( self . wizard_url , post_data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:2> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:3> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> all_data = response . context [ '<STR_LIT>' ] <EOL> self . assertEqual ( all_data [ '<STR_LIT>' ] . read ( ) , open ( __file__ ) . read ( ) ) <EOL> del all_data [ '<STR_LIT>' ] <EOL> self . assertEqual ( all_data , { <EOL> '<STR_LIT:name>' : u'<STR_LIT>' , '<STR_LIT>' : True , '<STR_LIT:user>' : self . testuser , <EOL> '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT>' : u'<STR_LIT>' , <EOL> '<STR_LIT>' : u'<STR_LIT>' , '<STR_LIT>' : [ <EOL> { '<STR_LIT>' : u'<STR_LIT>' } , <EOL> { '<STR_LIT>' : u'<STR_LIT>' } ] } ) <EOL> def test_manipulated_data ( self ) : <EOL> response = self . client . get ( self . wizard_url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> post_data = self . wizard_step_data [ <NUM_LIT:1> ] <EOL> post_data [ '<STR_LIT>' ] = open ( __file__ ) <EOL> response = self . client . post ( self . wizard_url , post_data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:2> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . client . cookies . pop ( '<STR_LIT>' , None ) <EOL> self . client . cookies . pop ( '<STR_LIT>' , None ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:3> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> def test_form_refresh ( self ) : <EOL> response = self . client . get ( self . wizard_url ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> post_data = self . wizard_step_data [ <NUM_LIT:1> ] <EOL> post_data [ '<STR_LIT>' ] = open ( __file__ ) <EOL> response = self . client . post ( self . wizard_url , post_data ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:2> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . context [ '<STR_LIT>' ] [ '<STR_LIT>' ] . current , '<STR_LIT>' ) <EOL> response = self . client . post ( self . wizard_url , self . wizard_step_data [ <NUM_LIT:3> ] ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> class SessionWizardTests ( WizardTests , TestCase ) : <EOL> wizard_url = '<STR_LIT>' <EOL> wizard_step_1_data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> wizard_step_data = ( <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> ) <EOL> class CookieWizardTests ( WizardTests , TestCase ) : <EOL> wizard_url = '<STR_LIT>' <EOL> wizard_step_1_data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> wizard_step_data = ( <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> ) <EOL> class WizardTestKwargs ( TestCase ) : <EOL> wizard_url = '<STR_LIT>' <EOL> wizard_step_1_data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> wizard_step_data = ( <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> ) <EOL> urls = '<STR_LIT>' <EOL> def setUp ( self ) : <EOL> self . testuser , created = User . objects . get_or_create ( username = '<STR_LIT>' ) <EOL> self . wizard_step_data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] = self . testuser . pk <EOL> def test_template ( self ) : <EOL> templates = os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' ) <EOL> with self . settings ( <EOL> TEMPLATE_DIRS = list ( settings . TEMPLATE_DIRS ) + [ templates ] ) : <EOL> response = self . client . get ( self . wizard_url ) <EOL> self . assertTemplateUsed ( response , '<STR_LIT>' ) </s>
