mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-16 11:20:12 -04:00
Service name uniqueness handled in all cases and tests passing.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import uuid
|
||||
from datetime import date, datetime, timedelta
|
||||
from unittest.mock import Mock
|
||||
import pytest
|
||||
|
||||
from app import create_app
|
||||
@@ -18,6 +19,8 @@ from app.notify_client.models import (
|
||||
InvitedUser
|
||||
)
|
||||
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def app_(request):
|
||||
@@ -90,6 +93,24 @@ def mock_update_service(mocker):
|
||||
'app.notifications_api_client.update_service', side_effect=_update)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_update_service_raise_httperror_duplicate_name(mocker):
|
||||
|
||||
def _update(service_id,
|
||||
service_name,
|
||||
active,
|
||||
limit,
|
||||
restricted,
|
||||
users):
|
||||
json_mock = Mock(return_value={'message': {'name': ["Duplicate service name '{}'".format(service_name)]}})
|
||||
resp_mock = Mock(status_code=400, json=json_mock)
|
||||
http_error = HTTPError(response=resp_mock, message="Default message")
|
||||
raise http_error
|
||||
|
||||
return mocker.patch(
|
||||
'app.notifications_api_client.update_service', side_effect=_update)
|
||||
|
||||
|
||||
SERVICE_ONE_ID = "596364a0-858e-42c8-9062-a8fe822260eb"
|
||||
SERVICE_TWO_ID = "147ad62a-2951-4fa1-9ca0-093cd1a52c52"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user