aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2019-04-27 18:05:57 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2019-04-27 18:05:57 +0200
commit089bf272f0e4cf0a68b1490968d3339d15d1b9be (patch)
tree3cb6735b607206ac135a0612fc64a0d000427335
parent54a757b016d5b3aa9103ec29d6b63cd5fd64d28e (diff)
Improve tests for config
-rwxr-xr-xpyactivitypubd2
-rw-r--r--pyapd/config.py9
-rw-r--r--tests/test_config.py1
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 "<pyapd configuration from {}>".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)