add some unit tests

This commit is contained in:
Robert Kaussow 2019-04-15 11:20:12 +02:00
parent e1f6aec6b2
commit 248de52360
3 changed files with 36 additions and 1 deletions

View File

@ -34,10 +34,10 @@ class Settings(object):
"""
self.config_file = config_file
self.schema = None
self.args_files = False
self.args = self._set_args(args)
self.config = self._get_config()
self.schema = None
self._update_filelist()
def _set_args(self, args):
@ -132,6 +132,7 @@ class Settings(object):
},
},
}
self.schema = anyconfig.gen_schema(defaults)
return defaults

View File

@ -7,6 +7,15 @@ import colorama
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):
log = logger.get_logger("test_critical")
log.critical("foo")

View 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