@@ -15,7 +15,7 @@ def setUp(self):
1515 self .command2 = "2\n "
1616 self .command3 = "3\n "
1717
18- command_filename = os .path .join (self ._base_dir , "commant .txt" )
18+ command_filename = os .path .join (self ._base_dir , "commands .txt" )
1919
2020 with open (command_filename , "w+" ) as commands_file :
2121 commands_file .write (self .command1 + self .command2 + self .command3 )
@@ -40,6 +40,25 @@ def test_set_commands_to_run(self):
4040
4141 assert_true (not os .path .isfile (self .command_manager ._finished_commands_filename ))
4242
43+ def test_get_failed_commands (self ):
44+ # Setup
45+ command = self .command_manager .get_command_to_run ()
46+ self .command_manager .set_running_command_as_finished (command , 1 )
47+
48+ # The function to test
49+ failed_commands = self .command_manager .get_failed_commands ()
50+
51+ # Test validation
52+ assert_equal (len (failed_commands ), 1 )
53+ assert_equal (failed_commands [0 ], self .command1 )
54+
55+ def test_get_failed_commands_empty (self ):
56+ # The function to test
57+ failed_commands = self .command_manager .get_failed_commands ()
58+
59+ # Test validation
60+ assert_equal (len (failed_commands ), 0 )
61+
4362 def test_get_command_to_run (self ):
4463 # The function to test
4564 command = self .command_manager .get_command_to_run ()
@@ -75,6 +94,28 @@ def test_set_running_command_as_finished(self):
7594 with open (self .command_manager ._finished_commands_filename , "r" ) as finished_commands_file :
7695 assert_equal (finished_commands_file .read (), self .command1 )
7796
97+ assert_true (not os .path .isfile (self .command_manager ._failed_commands_filename ))
98+
99+ def test_set_running_command_as_failed (self ):
100+ # SetUp
101+ command = self .command_manager .get_command_to_run ()
102+ error_code = 1
103+
104+ # The function to test
105+ self .command_manager .set_running_command_as_finished (command , error_code )
106+
107+ # Test validation
108+ with open (self .command_manager ._commands_filename , "r" ) as commands_file :
109+ assert_equal (commands_file .read (), self .command2 + self .command3 )
110+
111+ with open (self .command_manager ._running_commands_filename , "r" ) as running_commands_file :
112+ assert_equal (running_commands_file .read (), "" )
113+
114+ with open (self .command_manager ._failed_commands_filename , "r" ) as failed_commands_file :
115+ assert_equal (failed_commands_file .read (), self .command1 )
116+
117+ assert_true (not os .path .isfile (self .command_manager ._finished_commands_filename ))
118+
78119 def test_reset_running_commands (self ):
79120 # SetUp
80121 self .command_manager .get_command_to_run ()
0 commit comments