Skip to content

Commit

Permalink
added few tests, small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
din14970 committed Feb 4, 2021
1 parent 73284b6 commit 147c0b1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pymatchseries/config_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
48 changes: 48 additions & 0 deletions pymatchseries/tests/test_config_tools.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 147c0b1

Please sign in to comment.