mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Reduce the errors related to user fixtures
We were using user fixtures in a lot of parameterized tests, but this is no longer allowed in Pytest 5. To avoid having to split up the parametrized tests (which would make the test files a lot longer and slightly more difficult to read) this commit creates functions which return various types of user json so that we can use these as the test parameters instead.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import uuid
|
||||
from datetime import date
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -9,7 +8,11 @@ from app.models.service import Service
|
||||
from app.notify_client import NotifyAdminAPIClient
|
||||
from app.notify_client.notification_api_client import notification_api_client
|
||||
from tests import service_json
|
||||
from tests.conftest import api_user_active, platform_admin_user, set_config
|
||||
from tests.conftest import (
|
||||
create_api_user_active,
|
||||
create_platform_admin_user,
|
||||
set_config,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('method', [
|
||||
@@ -18,8 +21,8 @@ from tests.conftest import api_user_active, platform_admin_user, set_config
|
||||
'delete'
|
||||
])
|
||||
@pytest.mark.parametrize('user', [
|
||||
api_user_active(str(uuid.uuid4())),
|
||||
platform_admin_user(str(uuid.uuid4()))
|
||||
create_api_user_active(),
|
||||
create_platform_admin_user(),
|
||||
], ids=['api_user', 'platform_admin'])
|
||||
@pytest.mark.parametrize('service', [
|
||||
service_json(active=True),
|
||||
|
||||
@@ -5,7 +5,7 @@ import pytest
|
||||
|
||||
from app import invite_api_client, service_api_client, user_api_client
|
||||
from tests import sample_uuid
|
||||
from tests.conftest import SERVICE_ONE_ID, api_user_pending
|
||||
from tests.conftest import SERVICE_ONE_ID
|
||||
|
||||
user_id = sample_uuid()
|
||||
|
||||
@@ -193,7 +193,7 @@ def test_returns_value_from_cache(
|
||||
(user_api_client, 'add_user_to_service', [SERVICE_ONE_ID, user_id, [], []], {}),
|
||||
(user_api_client, 'add_user_to_organisation', [sample_uuid(), user_id], {}),
|
||||
(user_api_client, 'set_user_permissions', [user_id, SERVICE_ONE_ID, []], {}),
|
||||
(user_api_client, 'activate_user', [api_user_pending(sample_uuid())['id']], {}),
|
||||
(user_api_client, 'activate_user', [user_id], {}),
|
||||
(user_api_client, 'archive_user', [user_id], {}),
|
||||
(service_api_client, 'remove_user_from_service', [SERVICE_ONE_ID, user_id], {}),
|
||||
(service_api_client, 'create_service', ['', '', 0, False, user_id, sample_uuid()], {}),
|
||||
|
||||
Reference in New Issue
Block a user