mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 08:31:00 -04:00
Stop calling fake_uuid fixture directly
Pytest is deprecating the direct calling of fixtures. One fixture that we call directly quite a lot is `fake_uuid`. Since it just returns the value of `sample_uuid()` we can either call that instead (where we need a fixed value) or generate a new UUID each time (where a fixed value is not needed).
This commit is contained in:
@@ -1,29 +1,28 @@
|
||||
from unittest.mock import call
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
|
||||
from app import invite_api_client, service_api_client, user_api_client
|
||||
from app.notify_client.service_api_client import ServiceAPIClient
|
||||
from tests.conftest import SERVICE_ONE_ID, fake_uuid
|
||||
from tests.conftest import SERVICE_ONE_ID
|
||||
|
||||
FAKE_TEMPLATE_ID = fake_uuid()
|
||||
FAKE_TEMPLATE_ID = uuid4()
|
||||
|
||||
|
||||
def test_client_posts_archived_true_when_deleting_template(mocker):
|
||||
service_id = fake_uuid()
|
||||
template_id = fake_uuid()
|
||||
mocker.patch('app.notify_client.current_user', id='1')
|
||||
|
||||
expected_data = {
|
||||
'archived': True,
|
||||
'created_by': '1'
|
||||
}
|
||||
expected_url = '/service/{}/template/{}'.format(service_id, template_id)
|
||||
expected_url = '/service/{}/template/{}'.format(SERVICE_ONE_ID, FAKE_TEMPLATE_ID)
|
||||
|
||||
client = ServiceAPIClient()
|
||||
mock_post = mocker.patch('app.notify_client.service_api_client.ServiceAPIClient.post')
|
||||
|
||||
client.delete_service_template(service_id, template_id)
|
||||
client.delete_service_template(SERVICE_ONE_ID, FAKE_TEMPLATE_ID)
|
||||
mock_post.assert_called_once_with(expected_url, data=expected_data)
|
||||
|
||||
|
||||
@@ -361,8 +360,8 @@ def test_returns_value_from_cache(
|
||||
(service_api_client, 'delete_sms_sender', [SERVICE_ONE_ID, ''], {}),
|
||||
(service_api_client, 'update_service_callback_api', [SERVICE_ONE_ID] + [''] * 4, {}),
|
||||
(service_api_client, 'create_service_callback_api', [SERVICE_ONE_ID] + [''] * 3, {}),
|
||||
(user_api_client, 'add_user_to_service', [SERVICE_ONE_ID, fake_uuid(), []], {}),
|
||||
(invite_api_client, 'accept_invite', [SERVICE_ONE_ID, fake_uuid()], {}),
|
||||
(user_api_client, 'add_user_to_service', [SERVICE_ONE_ID, uuid4(), []], {}),
|
||||
(invite_api_client, 'accept_invite', [SERVICE_ONE_ID, uuid4()], {}),
|
||||
])
|
||||
def test_deletes_service_cache(
|
||||
app_,
|
||||
|
||||
@@ -4,9 +4,10 @@ import pytest
|
||||
|
||||
from app import invite_api_client, service_api_client, user_api_client
|
||||
from app.notify_client.models import User
|
||||
from tests.conftest import SERVICE_ONE_ID, api_user_pending, fake_uuid
|
||||
from tests import sample_uuid
|
||||
from tests.conftest import SERVICE_ONE_ID, api_user_pending
|
||||
|
||||
user_id = fake_uuid()
|
||||
user_id = sample_uuid()
|
||||
|
||||
|
||||
def test_client_gets_all_users_for_service(
|
||||
@@ -236,7 +237,7 @@ def test_returns_value_from_cache(
|
||||
|
||||
|
||||
@pytest.mark.parametrize('client, method, extra_args, extra_kwargs', [
|
||||
(user_api_client, 'add_user_to_service', [SERVICE_ONE_ID, fake_uuid(), []], {}),
|
||||
(user_api_client, 'add_user_to_service', [SERVICE_ONE_ID, sample_uuid(), []], {}),
|
||||
(user_api_client, 'update_user_attribute', [user_id], {}),
|
||||
(user_api_client, 'reset_failed_login_count', [user_id], {}),
|
||||
(user_api_client, 'update_user_attribute', [user_id], {}),
|
||||
@@ -244,11 +245,11 @@ def test_returns_value_from_cache(
|
||||
(user_api_client, 'verify_password', [user_id, 'hunter2'], {}),
|
||||
(user_api_client, 'check_verify_code', [user_id, '', ''], {}),
|
||||
(user_api_client, 'add_user_to_service', [SERVICE_ONE_ID, user_id, []], {}),
|
||||
(user_api_client, 'add_user_to_organisation', [fake_uuid(), 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(fake_uuid())], {}),
|
||||
(user_api_client, 'activate_user', [api_user_pending(sample_uuid())], {}),
|
||||
(service_api_client, 'remove_user_from_service', [SERVICE_ONE_ID, user_id], {}),
|
||||
(service_api_client, 'create_service', ['', '', 0, False, user_id, fake_uuid()], {}),
|
||||
(service_api_client, 'create_service', ['', '', 0, False, user_id, sample_uuid()], {}),
|
||||
(invite_api_client, 'accept_invite', [SERVICE_ONE_ID, user_id], {}),
|
||||
])
|
||||
def test_deletes_user_cache(
|
||||
|
||||
Reference in New Issue
Block a user