From 089bf272f0e4cf0a68b1490968d3339d15d1b9be Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sat, 27 Apr 2019 18:05:57 +0200 Subject: Improve tests for config --- pyactivitypubd | 2 +- pyapd/config.py | 9 +++++++-- tests/test_config.py | 1 - 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pyactivitypubd b/pyactivitypubd index 97786bb..4d9e63e 100755 --- a/pyactivitypubd +++ b/pyactivitypubd @@ -6,7 +6,7 @@ from pyapd import app, config if __name__ == "__main__": - config = config.Config + config = config.Config() apd = app.App(config) apd.listen(8888) tornado.ioloop.IOLoop.current().start() diff --git a/pyapd/config.py b/pyapd/config.py index 83e35b4..fd01435 100644 --- a/pyapd/config.py +++ b/pyapd/config.py @@ -7,8 +7,7 @@ class Config(): def __init__(self, config_fn: Optional[str] = None, **kw): self.config_fn = config_fn self.data: dict = {} - if config_fn: - self.load() + self.load() def __getattr__(self, name): try: @@ -16,6 +15,12 @@ class Config(): except KeyError as e: raise NameError(e) + def __str__(self): + return "".format(self.config_fn) + + def __repr__(self): + return str(self.data) + def load(self, config_fn: Optional[str] = None): if config_fn: self.config_fn = config_fn diff --git a/tests/test_config.py b/tests/test_config.py index 6002dd9..507c322 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -8,7 +8,6 @@ class TestConfig(unittest.TestCase): self.config = config.Config() def test_load_config_no_files(self): - self.config.load() self.assertEqual(self.config.config_fn, 'pyapd_config.yaml') self.assertIn('backend', self.config.data) -- cgit v1.2.3