From 147c0b14dbdeaf450cb3d50c61ce6224d6c169bf Mon Sep 17 00:00:00 2001 From: Niels Cautaerts Date: Thu, 4 Feb 2021 20:20:34 +0100 Subject: [PATCH] added few tests, small fix --- pymatchseries/config_tools.py | 2 +- pymatchseries/tests/test_config_tools.py | 48 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 pymatchseries/tests/test_config_tools.py diff --git a/pymatchseries/config_tools.py b/pymatchseries/config_tools.py index 9a0b3f0..896bab3 100644 --- a/pymatchseries/config_tools.py +++ b/pymatchseries/config_tools.py @@ -180,5 +180,5 @@ def create_config_file(filename, *args, **kwargs): saveNamedDeformedDMXTemplatesAsDMX : bool, optional saveRefAndTempl : bool, optional """ - get_configuration(*args, **kwargs) + config_dict = get_configuration(*args, **kwargs) config_dict.save(filename) diff --git a/pymatchseries/tests/test_config_tools.py b/pymatchseries/tests/test_config_tools.py new file mode 100644 index 0000000..832d9e8 --- /dev/null +++ b/pymatchseries/tests/test_config_tools.py @@ -0,0 +1,48 @@ +from pymatchseries import config_tools as ctools +import os +import pytest + + +def test_load_config(): + ctools.load_config() + + +def test_write_config(): + dummy = ctools.load_config() + ctools.write_config(dummy, "test_config.par") + assert os.path.isfile("test_config.par") + os.remove("test_config.par") + + +def test_get_configuration(): + c = ctools.get_configuration("test", "test", 2, + 1, [1, 2, 3], + preSmoothSigma=1) + assert isinstance(c, ctools.config_dict) + + +def test_create_config_file(): + ctools.create_config_file("test.par", "test", "test", 2, + 1, [1, 2, 3], + preSmoothSigma=1) + assert os.path.isfile("test.par") + os.remove("test.par") + + +class TestConfigDict(): + + def test_init(self): + testdict = {"foo": "bar", "batman": 1} + c = ctools.config_dict(testdict) + assert isinstance(c, ctools.config_dict) + + def test_get(self): + testdict = {"foo": "bar", "batman": 1} + c = ctools.config_dict(testdict) + assert c.foo == "bar" + + def test_set(self): + testdict = {"foo": "bar", "batman": 1} + c = ctools.config_dict(testdict) + c.foo == "foo" + assert c.foo == "bar"