aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2019-04-13 18:32:19 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2019-04-13 18:32:19 +0200
commit3c33ddd2f85ac5475539cd1c5eae2f30fb9e6ea8 (patch)
treeb03b071e32f1633f6aaada41f4fa7505d74263d0
parent9b337be1a6e392923509fa94435164b0da98960d (diff)
Config for tests
-rwxr-xr-xpyactivitypubd5
-rw-r--r--pyapd/app.py3
-rw-r--r--tests/data/test_config.yaml (renamed from tests/data/simple_config.yaml)0
-rw-r--r--tests/test_app.py4
-rw-r--r--tests/test_config.py4
5 files changed, 9 insertions, 7 deletions
diff --git a/pyactivitypubd b/pyactivitypubd
index d89dd96..97786bb 100755
--- a/pyactivitypubd
+++ b/pyactivitypubd
@@ -2,10 +2,11 @@
import tornado.ioloop
-from pyapd import app
+from pyapd import app, config
if __name__ == "__main__":
- apd = app.App()
+ config = config.Config
+ apd = app.App(config)
apd.listen(8888)
tornado.ioloop.IOLoop.current().start()
diff --git a/pyapd/app.py b/pyapd/app.py
index b470688..0eaa80f 100644
--- a/pyapd/app.py
+++ b/pyapd/app.py
@@ -7,7 +7,8 @@ class RootHandler(tornado.web.RequestHandler):
class App(tornado.web.Application):
- def __init__(self, *args, **kw):
+ def __init__(self, config, *args, **kw):
+ self.config = config
urls = [
(r'/', RootHandler),
]
diff --git a/tests/data/simple_config.yaml b/tests/data/test_config.yaml
index fa44e32..fa44e32 100644
--- a/tests/data/simple_config.yaml
+++ b/tests/data/test_config.yaml
diff --git a/tests/test_app.py b/tests/test_app.py
index a2ff27a..1ff504c 100644
--- a/tests/test_app.py
+++ b/tests/test_app.py
@@ -1,11 +1,11 @@
from tornado.testing import AsyncHTTPTestCase
-from pyapd import app
+from pyapd import app, config
class TestApp(AsyncHTTPTestCase):
def get_app(self, *args, **kw):
- return app.App()
+ return app.App(config.Config('tests/data/test_config.yaml'))
def test_root(self):
res = self.fetch('/')
diff --git a/tests/test_config.py b/tests/test_config.py
index 37f057e..7851019 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -13,10 +13,10 @@ class TestConfig(unittest.TestCase):
self.assertIn('backend', self.config.data)
def test_load_config_from_file(self):
- self.config.load('tests/data/simple_config.yaml')
+ self.config.load('tests/data/test_config.yaml')
self.assertEqual(
self.config.config_fn,
- 'tests/data/simple_config.yaml'
+ 'tests/data/test_config.yaml'
)
self.assertIn('backend', self.config.data)
self.assertEqual(self.config.backend, 'none')