[tests] Changed GET calls to proper REST

This commit is contained in:
maike 2020-07-13 14:05:02 +02:00 committed by dl6tom
parent 5b3ac2be75
commit 2815f70bf8
2 changed files with 9 additions and 6 deletions

View file

@ -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

View file

@ -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'