diff --git a/sumo_project/tests/configurator_tests.py b/sumo_project/tests/configurator_tests.py index 52c9673..a8c9fc3 100644 --- a/sumo_project/tests/configurator_tests.py +++ b/sumo_project/tests/configurator_tests.py @@ -1,3 +1,4 @@ +import io import os import shutil import tempfile @@ -110,5 +111,33 @@ class GenerationTests(unittest.TestCase): self.assertTrue(os.path.isdir(path), msg=f'{path} is not a directory') +class InputTests(unittest.TestCase): + def test_commandline(self): + options = ['--name', 'test-config', '--path', '/some/path', '--vclass', 'passenger=10', 'truck=1', '--', 'test.osm'] + actual_conf = configurator.parse_command_line(options) + self.assertEqual(actual_conf.name, 'test-config') + self.assertEqual(actual_conf.osmfile, 'test.osm') + self.assertEqual(actual_conf.path, '/some/path') + self.assertEqual(actual_conf.vclasses, {'passenger': '10', 'truck': '1'}) + + def test_from_config_file(self): + options = """ + { + "name": "test-config", + "path": "/some/path", + "vclasses": { + "passenger": 10, + "truck": 1 + }, + "osmfile": "test.osm" + } + """ + actual_conf = configurator.parse_json(io.StringIO(options)) + self.assertEqual(actual_conf.name, 'test-config') + self.assertEqual(actual_conf.osmfile, 'test.osm') + self.assertEqual(actual_conf.path, '/some/path') + self.assertEqual(actual_conf.vclasses, {'passenger': 10, 'truck': 1}) + + if __name__ == '__main__': unittest.main()