aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2019-06-10 11:44:51 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2019-06-10 11:44:51 +0200
commitf39b4f955e855897414610c729fc6da9ab2df2f1 (patch)
tree252d2ccfba54255203c39ecf257c176a5614feb7 /tests
parent643e6c89834728af8746249ba856cf65279cb102 (diff)
Add ctl command to add arbitrary objects
Diffstat (limited to 'tests')
-rw-r--r--tests/test_ctl.py32
1 files changed, 27 insertions, 5 deletions
diff --git a/tests/test_ctl.py b/tests/test_ctl.py
index ddac775..f58ce5a 100644
--- a/tests/test_ctl.py
+++ b/tests/test_ctl.py
@@ -3,18 +3,40 @@ import tempfile
from tornado.testing import AsyncTestCase, gen_test
-from pyapd import ctl, config
+from pyapd import ctl, config, app
-class TestCtlServer(AsyncTestCase):
+class TestCtlServerCommands(AsyncTestCase):
def setUp(self):
super().setUp()
self.tempdir = tempfile.TemporaryDirectory()
- conf = config.Config('tests/data/test_config.yaml')
- conf.ctl_socket = os.path.join(self.tempdir.name, 'pyapd.sock')
- self.ctl_server = ctl.CtlServer(conf)
+ test_app = app.App(config.Config('tests/data/test_config.yaml'))
+ test_app.config.ctl_socket = os.path.join(
+ self.tempdir.name,
+ 'pyapd.sock'
+ )
+ self.ctl_server = ctl.CtlServer(test_app)
@gen_test
def test_ping_command(self):
res = yield self.ctl_server.get_command('{"command": "ping"}')
self.assertIn('pong', res)
+
+ @gen_test
+ def test_add_object_command(self):
+ self.assertEqual(len(self.ctl_server.app.store.objects), 0)
+ obj = '''
+ {
+ "id": "http://example.org/123456",
+ "type": "object"
+ }
+ '''
+ res = yield (self.ctl_server.get_command('''
+ {{
+ "command": "add_object",
+ "obj": {obj}
+ }}
+ '''.format(obj=obj)
+ ))
+ self.assertIn('ok', res)
+ self.assertEqual(len(self.ctl_server.app.store.objects), 1)