UT: Add tests for new RegistrationStatus resource

This commit is contained in:
Shreya Malviya 2022-08-02 14:22:18 +05:30
parent 3dc2edcdc1
commit 4801235c4b
2 changed files with 16 additions and 9 deletions

View File

@ -62,12 +62,3 @@ def test_internal_error(make_registration_request, mock_authentication_service):
response = make_registration_request(registration_request_body)
assert response.status_code == 500
@pytest.mark.parametrize("needs_registration", [True, False])
def test_needs_registration(flask_client, mock_authentication_service, needs_registration):
mock_authentication_service.needs_registration = MagicMock(return_value=needs_registration)
response = flask_client.get(REGISTRATION_URL, follow_redirects=True)
assert response.status_code == 200
assert response.json["needs_registration"] is needs_registration

View File

@ -0,0 +1,16 @@
from unittest.mock import MagicMock
import pytest
from monkey_island.cc.resources.auth.registration_status import RegistrationStatus
REGISTRATION_STATUS_URL = RegistrationStatus.urls[0]
@pytest.mark.parametrize("needs_registration", [True, False])
def test_needs_registration(flask_client, mock_authentication_service, needs_registration):
mock_authentication_service.needs_registration = MagicMock(return_value=needs_registration)
response = flask_client.get(REGISTRATION_STATUS_URL, follow_redirects=True)
assert response.status_code == 200
assert response.json["needs_registration"] is needs_registration