summaryrefslogtreecommitdiff
path: root/web-server/opendc/api/v2/prefabs/test_endpoint.py
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-07-07 17:50:32 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:47:54 +0200
commit232d27805eb598290f75c170d912a86c6b96afed (patch)
tree2c9ed648fc2e2b2b8b066e4bd9e525a367b8a020 /web-server/opendc/api/v2/prefabs/test_endpoint.py
parente41abaef98166dcd5c0bba75edff80ab8db9921a (diff)
parent223e916997eb641a1662110b6de630a4cdfdf479 (diff)
Merge remote-tracking branch 'origin/feature/mongodb-migration' into feature/mongodb-migration
Diffstat (limited to 'web-server/opendc/api/v2/prefabs/test_endpoint.py')
-rw-r--r--web-server/opendc/api/v2/prefabs/test_endpoint.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/web-server/opendc/api/v2/prefabs/test_endpoint.py b/web-server/opendc/api/v2/prefabs/test_endpoint.py
new file mode 100644
index 00000000..58735ac7
--- /dev/null
+++ b/web-server/opendc/api/v2/prefabs/test_endpoint.py
@@ -0,0 +1,21 @@
+from opendc.util.database import DB
+
+
+def test_add_simulation_missing_parameter(client):
+ assert '400' in client.post('/api/v2/prefabs').status
+
+
+def test_add_simulation(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'
+ })
+ mocker.patch.object(DB, 'update', return_value={})
+ res = client.post('/api/v2/prefabs', json={'prefab': {'name': 'test prefab'}})
+ assert 'datetimeCreated' in res.json['content']
+ assert 'datetimeLastEdited' in res.json['content']
+ assert '200' in res.status