mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-25 22:30:42 +00:00
add some unit tests
This commit is contained in:
parent
e1f6aec6b2
commit
248de52360
@ -34,10 +34,10 @@ class Settings(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
self.config_file = config_file
|
self.config_file = config_file
|
||||||
|
self.schema = None
|
||||||
self.args_files = False
|
self.args_files = False
|
||||||
self.args = self._set_args(args)
|
self.args = self._set_args(args)
|
||||||
self.config = self._get_config()
|
self.config = self._get_config()
|
||||||
self.schema = None
|
|
||||||
self._update_filelist()
|
self._update_filelist()
|
||||||
|
|
||||||
def _set_args(self, args):
|
def _set_args(self, args):
|
||||||
@ -132,6 +132,7 @@ class Settings(object):
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
self.schema = anyconfig.gen_schema(defaults)
|
self.schema = anyconfig.gen_schema(defaults)
|
||||||
|
|
||||||
return defaults
|
return defaults
|
||||||
|
@ -7,6 +7,15 @@ import colorama
|
|||||||
from ansiblelater import logger
|
from ansiblelater import logger
|
||||||
|
|
||||||
|
|
||||||
|
def test_flag_extra():
|
||||||
|
extra = {}
|
||||||
|
extra.update(foo="bar")
|
||||||
|
|
||||||
|
flagged = logger.flag_extra(extra)
|
||||||
|
|
||||||
|
assert flagged.get("later_foo") == "bar"
|
||||||
|
|
||||||
|
|
||||||
def test_critical(capsys, mocker):
|
def test_critical(capsys, mocker):
|
||||||
log = logger.get_logger("test_critical")
|
log = logger.get_logger("test_critical")
|
||||||
log.critical("foo")
|
log.critical("foo")
|
25
ansiblelater/tests/unit/test_settings.py
Normal file
25
ansiblelater/tests/unit/test_settings.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from ansiblelater import settings
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def settings_instance():
|
||||||
|
c = settings.Settings(args={"rules": {"files": []}})
|
||||||
|
|
||||||
|
return c
|
||||||
|
|
||||||
|
|
||||||
|
def test_args_member(settings_instance):
|
||||||
|
x = {"rules": {"files": ["*"]}}
|
||||||
|
|
||||||
|
assert x == settings_instance.args
|
||||||
|
|
||||||
|
|
||||||
|
def test_args_setter(settings_instance):
|
||||||
|
default = {"rules.files": ["dummy"], "config_file": "conf.yml"}
|
||||||
|
x = {"rules": {"files": ["dummy"]}}
|
||||||
|
|
||||||
|
s = settings_instance._set_args(default)
|
||||||
|
|
||||||
|
assert x == s
|
Loading…
Reference in New Issue
Block a user