From 2815f70bf8bf220e1694f56ae7b377123a9fe464 Mon Sep 17 00:00:00 2001 From: maike Date: Mon, 13 Jul 2020 14:05:02 +0200 Subject: [PATCH] [tests] Changed GET calls to proper REST --- tests/test_api_email_happy_path.py | 6 ++++-- tests/test_api_email_wrong.py | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/test_api_email_happy_path.py b/tests/test_api_email_happy_path.py index 7983593..984a14e 100644 --- a/tests/test_api_email_happy_path.py +++ b/tests/test_api_email_happy_path.py @@ -30,7 +30,9 @@ def test_email_subscribe(client, hood_id, email_row): logger.removeHandler(capture) assert response.status_code == status.HTTP_502_BAD_GATEWAY token = capture.records[0].message - response = client.get('/api/hoods/%d/email/subscribe/confirm/%s' % (hood_id, token)) + response = client.post( + '/api/hoods/%d/email/subscribe/confirm/%s' % (hood_id, token) + ) assert response.status_code == status.HTTP_201_CREATED # response = client.get('/api/hoods/%d/email/subscribe/confirm/%s' % (hood_id, token)) # assert response.status_code == status.HTTP_409_CONFLICT @@ -49,7 +51,7 @@ def test_email_message(client, hood_id, trigger_id, email_row): def test_email_unsubscribe(client, hood_id, email_row): test_email_subscribe(client, hood_id, email_row) token = to_token(email="user@localhost", hood=hood_id) - response = client.get('/api/hoods/%d/email/unsubscribe/%s' % (hood_id, token)) + response = client.delete('/api/hoods/%d/email/unsubscribe/%s' % (hood_id, token)) assert response.status_code == status.HTTP_204_NO_CONTENT diff --git a/tests/test_api_email_wrong.py b/tests/test_api_email_wrong.py index 1e1a8d8..705e201 100644 --- a/tests/test_api_email_wrong.py +++ b/tests/test_api_email_wrong.py @@ -13,16 +13,17 @@ def test_email_subscribe_empty(client, hood_id): def test_email_subscribe_confirm_wrong_token(client, hood_id): try: - client.get( + response = client.post( '/api/hoods/%d/email/subscribe/confirm/asdfasdfasdfasdfasdfasdfasdfasdf' % hood_id ) + assert response.status_code is not status.HTTP_201_CREATED except CryptoError: pass def test_email_subscribe_confirm_wrong_hood(client): - response = client.get( + response = client.delete( '/api/hoods/99999/email/unsubscribe/asdfasdfasdfasdfasdfasdfasdfasdf' ) assert response.json()['detail'] == 'Not Found' @@ -40,7 +41,7 @@ def test_email_message_wrong(client, hood_id, email_row): def test_email_unsubscribe_wrong_token(client, hood_id): try: - client.get( + client.delete( '/api/hoods/%d/email/unsubscribe/asdfasdfasdfasdfasdfasdfasdfasdf' % hood_id ) except CryptoError: @@ -48,7 +49,7 @@ def test_email_unsubscribe_wrong_token(client, hood_id): def test_email_unsubscribe_wrong_hood(client): - response = client.get( + response = client.delete( '/api/hoods/99999/email/unsubscribe/asdfasdfasdfasdfasdfasdfasdfasdf' ) assert response.json()['detail'] == 'Not Found'