From 7a565e0511dcc9deabe9ddcdf36788697074baec Mon Sep 17 00:00:00 2001 From: Fabian Date: Fri, 8 May 2020 21:25:18 +0200 Subject: [PATCH] Fixed consumer test --- consumer_api/tests/consumers_view_test.py | 2 +- consumer_api/tests/sync_view_test.py | 30 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 consumer_api/tests/sync_view_test.py diff --git a/consumer_api/tests/consumers_view_test.py b/consumer_api/tests/consumers_view_test.py index 9a80230..dbb1b3d 100644 --- a/consumer_api/tests/consumers_view_test.py +++ b/consumer_api/tests/consumers_view_test.py @@ -12,6 +12,6 @@ def client(): def test_response_length(client): - r = client.post('/log') + r = client.get('/consumers') assert len(r) == 0 diff --git a/consumer_api/tests/sync_view_test.py b/consumer_api/tests/sync_view_test.py new file mode 100644 index 0000000..a7839f0 --- /dev/null +++ b/consumer_api/tests/sync_view_test.py @@ -0,0 +1,30 @@ +import json +import os + +import pytest + +from flask import current_app + + +@pytest.fixture +def client(): + current_app.config['TESTING'] = True + + with current_app.test_client() as client: + yield client + + +def test_log_code_get(client): + r = client.get('/sync') + + assert r.status_code == 405 + + +def test_log_code_post(client): + data = { + "uuid": os.environ["LOCAL_UUID"], + "message": "Hello There!" + } + r = client.post('/sync', data = json.dumps(data)) + + assert r.status_code == 204