mirror of
https://github.com/Ahp06/SUMO_Emissions.git
synced 2024-11-22 03:26:30 +00:00
Update tests
This commit is contained in:
parent
d5d6463c72
commit
426bd572dc
@ -1,3 +1,4 @@
|
|||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
@ -110,5 +111,33 @@ class GenerationTests(unittest.TestCase):
|
|||||||
self.assertTrue(os.path.isdir(path), msg=f'{path} is not a directory')
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user