<s> from vii . Dispatcher import Dispatcher , TokenExecption <EOL> from vii . Command import Command <EOL> from nose . tools import * <EOL> class FinshActionSeen ( Exception ) : pass <EOL> class Action : <EOL> finishSeen = False <EOL> def finish ( self ) : self . finishSeen = True <EOL> def act ( self ) : return "<STR_LIT>" <EOL> class ActionManager : <EOL> actionCalled = <NUM_LIT:0> <EOL> def action ( self , mode , operator ) : <EOL> self . actionCalled += <NUM_LIT:1> <EOL> return self . Action <EOL> class Dispatcher_Test : <EOL> def setup ( self ) : <EOL> self . fixture = Dispatcher ( ) <EOL> self . actionManager = ActionManager ( ) <EOL> self . action = Action ( ) <EOL> self . actionManager . Action = self . action <EOL> self . fixture . actionManager = self . actionManager <EOL> def test__init__ ( self ) : <EOL> fixture = Dispatcher ( ) <EOL> assert fixture . actionManager == None <EOL> assert fixture . currentMode == None <EOL> assert fixture . currentAction == None <EOL> assert fixture . currentCommand == None <EOL> assert fixture . forceTokenToString == False <EOL> @ raises ( TokenExecption ) <EOL> def test_stepInit_raises_exception_for_int ( self ) : <EOL> self . fixture . stepInit ( <NUM_LIT:1> ) <EOL> def test_stepInit ( self ) : <EOL> assert self . fixture . currentMode == None <EOL> assert self . fixture . currentAction == None <EOL> self . fixture . stepInit ( "<STR_LIT:a>" ) <EOL> assert self . fixture . currentMode == "<STR_LIT>" <EOL> assert self . fixture . currentAction == self . action <EOL> command = self . fixture . currentCommand <EOL> assert command . __class__ == Command <EOL> def test_stepCommand_inserts ( self ) : <EOL> self . fixture . reset ( ) <EOL> self . fixture . currentMode = "<STR_LIT>" <EOL> inserts = self . fixture . currentCommand . lpInserts ( ) <EOL> assert inserts == [ ] <EOL> self . fixture . stepCommand ( "<STR_LIT:a>" ) <EOL> self . fixture . stepCommand ( "<STR_LIT:b>" ) <EOL> assert inserts == [ "<STR_LIT:a>" , "<STR_LIT:b>" ] <EOL> def test_stepCommand_normal ( self ) : <EOL> self . fixture . reset ( ) <EOL> self . fixture . currentMode = "<STR_LIT>" <EOL> self . fixture . stepCommand ( "<STR_LIT:1>" ) <EOL> self . fixture . stepCommand ( "<STR_LIT:2>" ) <EOL> assert self . fixture . forceTokenToString == False <EOL> assert self . fixture . currentCommand . lpReady ( ) == False <EOL> assert self . fixture . currentCommand . lpCount ( ) == <NUM_LIT:12> <EOL> self . fixture . stepCommand ( "<STR_LIT:a>" ) <EOL> assert self . fixture . forceTokenToString == True <EOL> assert self . fixture . currentCommand . lpReady ( ) == True <EOL> assert self . fixture . currentCommand . lpOperator ( ) == "<STR_LIT:a>" <EOL> def test_stepAction ( self ) : <EOL> pass <EOL> def test_extend ( self ) : <EOL> self . fixture . reset ( ) <EOL> assert self . fixture . forceTokenToString == False <EOL> self . fixture . forceTokenToString = True <EOL> self . fixture . extend ( ) <EOL> assert self . fixture . forceTokenToString == False <EOL> def test_reset ( self ) : <EOL> self . fixture . currentCommand = None <EOL> self . fixture . forceTokenToString = True <EOL> self . fixture . reset ( ) <EOL> assert self . fixture . forceTokenToString == False <EOL> command = self . fixture . currentCommand <EOL> assert command . __class__ == Command <EOL> assert len ( command . parts ) == <NUM_LIT:1> </s>
