<s> import unittest <EOL> import os <EOL> from nose . tools import assert_equals <EOL> from robotide . publish import PUBLISHER <EOL> from robotide . publish . messages import RideItemStepsChanged <EOL> from controller . controller_creator import ( <EOL> _FakeProject , testcase_controller , BASE_DATA ) <EOL> class TestCaseCommandTest ( unittest . TestCase , _FakeProject ) : <EOL> resource_file_controller_factory = None <EOL> def setUp ( self ) : <EOL> self . _steps = None <EOL> self . _data = self . _create_data ( ) <EOL> self . _ctrl = testcase_controller ( self , data = self . _data ) <EOL> PUBLISHER . subscribe ( self . _test_changed , RideItemStepsChanged ) <EOL> self . _orig_number_of_steps = len ( self . _ctrl . steps ) <EOL> self . _number_of_test_changes = <NUM_LIT:0> <EOL> def tearDown ( self ) : <EOL> if os . path . exists ( '<STR_LIT:path>' ) : <EOL> os . removedirs ( '<STR_LIT:path>' ) <EOL> def _create_data ( self ) : <EOL> return BASE_DATA [ : ] <EOL> def save ( self , controller ) : <EOL> self . _file_saved = ( controller == self . _ctrl . datafile_controller ) <EOL> def tearDown ( self ) : <EOL> PUBLISHER . unsubscribe ( self . _test_changed , RideItemStepsChanged ) <EOL> def _get_macros ( self ) : <EOL> return [ m for m in self . _ctrl . _parent ] <EOL> def _get_macro_by_name ( self , name ) : <EOL> return [ m for m in self . _get_macros ( ) if m . name == name ] [ <NUM_LIT:0> ] <EOL> def _data_row ( self , line ) : <EOL> return self . _data . index ( line ) - <NUM_LIT:1> <EOL> def _data_step_as_list ( self , step_data ) : <EOL> return step_data . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:1> : ] <EOL> def _exec ( self , command ) : <EOL> return self . _ctrl . execute ( command ) <EOL> def _test_changed ( self , data ) : <EOL> self . _number_of_test_changes += <NUM_LIT:1> <EOL> self . _steps = data . item . steps <EOL> def _verify_step_unchanged ( self , step_data ) : <EOL> row = self . _data_row ( step_data ) <EOL> assert_equals ( self . _steps [ row ] . as_list ( ) , self . _data_step_as_list ( step_data ) ) <EOL> def _verify_steps_unchanged ( self , * steps ) : <EOL> for step in steps : <EOL> self . _verify_step_unchanged ( step ) <EOL> def _verify_number_of_test_changes ( self , expected ) : <EOL> assert_equals ( self . _number_of_test_changes , expected ) <EOL> def _verify_row_does_not_exist ( self , line ) : <EOL> for step in self . _steps : <EOL> if step . as_list ( ) == self . _data_step_as_list ( line ) : <EOL> raise AssertionError ( '<STR_LIT>' % line ) <EOL> def _verify_step_is_empty ( self , index ) : <EOL> assert_equals ( self . _steps [ index ] . as_list ( ) , [ ] ) <EOL> def _verify_step ( self , index , exp_name , exp_args = [ ] , exp_comment = None ) : <EOL> exp = [ exp_name ] + exp_args <EOL> if exp_comment : <EOL> exp += [ exp_comment ] <EOL> assert_equals ( self . _steps [ index ] . as_list ( ) , exp ) <EOL> def _verify_step_number_change ( self , change ) : <EOL> assert_equals ( len ( self . _steps ) , self . _orig_number_of_steps + change ) </s>
