def test_model_copy(self): with patch.object(Arguments, "_identifier", return_value="2"): arguments = Arguments(["foo/test.mad", "25"]) expected = Arguments.PATH_TO_MODEL_COPY.format(directory="test_2", file="test.mad") self.assertEqual(expected, arguments.model_copy)
def test_all_output_directory_stays_the_same(self): arguments = None with patch.object(Arguments, "_identifier", return_value="2"): arguments = Arguments(["foo/test.mad", "23"]) self.assertEqual(arguments._output_directory, "test_2") with patch.object(Arguments, "_identifier", return_value="3"): self.assertEqual(arguments._output_directory, "test_2")
def test_output_directory_is_in_the_current_directory(self): Arguments._identifier = MagicMock(return_value="1") tests = [("foo/test.mad", "test_1"), ("foo/bar/test.mad", "test_1"), ("foo/bar\\test.mad", "test_1"), ("foo/bar\\test my file.mad", "test my file_1"), ("C:\\Users\\foo\\test.mad", "test_1"), ("/home/foo/test.mad", "test_1"), ("../test.mad", "test_1"), ("http://www.example.com/test.mad", "test_1")] for (each_path, each_expected_output) in tests: arguments = Arguments([each_path, "25"]) self.assertEquals(each_expected_output, arguments._output_directory)
def test_detecting_wrong_arguments(self): with self.assertRaises(InvalidSimulationModel): Arguments([25, "test.mad"]) with self.assertRaises(InvalidSimulationLength): Arguments(["test.mad", "25x"])
def test_detecting_missing_arguments(self): with self.assertRaises(WrongNumberOfArguments): Arguments([25])
def test_parsing_parameter(self): project = Arguments(["test.mad", "25"]) self.assertEqual("test.mad", project._file_name) self.assertEqual(25, project._time_limit)
def setUp(self): self.project = Arguments(["test.mad", "25"]) self.output = StringIO() self.display = Display(self.output)