def test_driver_duplicate_warning(self): with warnings.catch_warnings(record=True) as w: command_proc = CommandProcessor('test/test_data.txt') command_proc.driver_dict = {"Test Name": [0,0]} command_proc._driver(["Empty Data", "Empty Data"], "Test Name") assert len(w) == 1 assert issubclass(w[-1].category, RuntimeWarning) expec_dict = {"Test Name": [0,0]} assert command_proc.driver_dict == expec_dict
def test_run_command_trip_raises_error(self): with self.assertRaises(ValueError): command_proc = CommandProcessor('test/test_data.txt') command_proc._run_command(["in valid command", 'Test Name'], "Test Name")
def test_run_command_trip(self): with patch("src.command_processor.CommandProcessor._trip") as mock_command: command_proc = CommandProcessor('test/test_data.txt') command_proc._run_command(["Trip", "driver", "00:00", "01:00", "60"], "Test Name") self.assertTrue(mock_command.called)
def test_run_command_driver(self): with patch("src.command_processor.CommandProcessor._driver") as mock_command: command_proc = CommandProcessor('test/test_data.txt') command_proc._run_command(["Driver", 'Test Name'], "Test Name") self.assertTrue(mock_command.called)
def test_trip_under_5mph(self): command_proc = CommandProcessor('test/test_data.txt') command_proc.driver_dict = {"Test Name": [0,0]} command_proc._trip(["trip", "driver", "00:00", "01:00", "1"], "Test Name") expec_dict = {"Test Name": [0,0]} assert expec_dict == command_proc.driver_dict
def test_trip_driver_does_not_exists(self): with self.assertRaises(ValueError): command_proc = CommandProcessor('test/test_data.txt') command_proc.driver_dict = {} command_proc._trip(["trip", "driver", "00:00", "01:00", "60"], "Test Name")
def test_line_parser_removes_trailing_white_space(self): return_list = CommandProcessor('test/test_data.txt')._line_parser("test data\n") expec_list = ["test", "data"] assert return_list == expec_list
def test_driver_dict(self): command_proc = CommandProcessor('test/test_data.txt') command_proc._driver(["Empty Data", "Empty Data"], "Test Name") expec_dict = {"Test Name": [0,0]} assert command_proc.driver_dict == expec_dict
def test_line_parser_split(self): return_list = CommandProcessor('test/test_data.txt')._line_parser("1 2 3") expec_list = ["1", "2", "3"] assert return_list == expec_list
def test_line_parser_empty(self): return_list = CommandProcessor('test/test_data.txt')._line_parser("") self.assertIsInstance(return_list, list)
def test_line_parser_return_list(self): return_list = CommandProcessor('test/test_data.txt')._line_parser("testing the line parser") self.assertIsInstance(return_list, list)
def test_process_returns_correct_values(self): return_dict = CommandProcessor('test/test_data.txt').process() expec_dict = {'Dan': [50.0, 39.1], 'Alex': [75.0, 42.0], 'Bob': [0, 0]} self.assertEqual(return_dict, expec_dict)
def test_process_returns_dict(self): return_dict = CommandProcessor('test/test_data.txt').process() self.assertIsInstance(return_dict, dict)