summaryrefslogtreecommitdiff
path: root/api/opendc/api/v2/prefabs/test_endpoint.py
diff options
context:
space:
mode:
Diffstat (limited to 'api/opendc/api/v2/prefabs/test_endpoint.py')
-rw-r--r--api/opendc/api/v2/prefabs/test_endpoint.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/api/opendc/api/v2/prefabs/test_endpoint.py b/api/opendc/api/v2/prefabs/test_endpoint.py
new file mode 100644
index 00000000..47029579
--- /dev/null
+++ b/api/opendc/api/v2/prefabs/test_endpoint.py
@@ -0,0 +1,22 @@
+from opendc.util.database import DB
+
+
+def test_add_prefab_missing_parameter(client):
+ assert '400' in client.post('/api/v2/prefabs').status
+
+
+def test_add_prefab(client, mocker):
+ mocker.patch.object(DB, 'fetch_one', return_value={'_id': '1', 'authorizations': []})
+ mocker.patch.object(DB,
+ 'insert',
+ return_value={
+ '_id': '1',
+ 'datetimeCreated': '000',
+ 'datetimeLastEdited': '000',
+ 'authorId': 1
+ })
+ res = client.post('/api/v2/prefabs', json={'prefab': {'name': 'test prefab'}})
+ assert 'datetimeCreated' in res.json['content']
+ assert 'datetimeLastEdited' in res.json['content']
+ assert 'authorId' in res.json['content']
+ assert '200' in res.status