diff --git a/adit/batch_query/tests/integration/test_batch_query.py b/adit/batch_query/tests/integration/test_batch_query.py index 8b38ec57..c073213a 100644 --- a/adit/batch_query/tests/integration/test_batch_query.py +++ b/adit/batch_query/tests/integration/test_batch_query.py @@ -1,11 +1,13 @@ -from typing import Callable - import pandas as pd import pytest -from adit_radis_shared.accounts.models import User -from adit_radis_shared.common.utils.auth_utils import add_permission, add_user_to_group -from adit_radis_shared.common.utils.worker_utils import run_worker_once -from playwright.sync_api import Locator, Page, expect +from adit_radis_shared.common.utils.testing_helpers import ( + add_permission, + add_user_to_group, + create_and_login_example_user, + poll_locator, + run_worker_once, +) +from playwright.sync_api import Page, expect from pytest_django.live_server_helper import LiveServer from adit.batch_query.models import BatchQueryJob @@ -20,9 +22,7 @@ @pytest.mark.integration @pytest.mark.django_db(transaction=True) -def test_urgent_batch_query_with_dimse_server( - page: Page, poll: Callable[[Locator], Locator], live_server: LiveServer, create_and_login_user -): +def test_urgent_batch_query_with_dimse_server(page: Page, live_server: LiveServer): # Arrange df = pd.DataFrame( [["1005", "0062115904"]], @@ -30,7 +30,7 @@ def test_urgent_batch_query_with_dimse_server( ) batch_file = create_excel_file(df, "batch_file.xlsx") - user: User = create_and_login_user(live_server.url) + user = create_and_login_example_user(page, live_server.url) group = create_batch_query_group() add_user_to_group(user, group) add_permission(group, BatchQueryJob, "can_process_urgently") @@ -51,14 +51,12 @@ def test_urgent_batch_query_with_dimse_server( run_worker_once() # Assert - expect(poll(page.locator('dl:has-text("Success")'))).to_be_visible() + expect(poll_locator(page.locator('dl:has-text("Success")'))).to_be_visible() @pytest.mark.integration @pytest.mark.django_db(transaction=True) -def test_urgent_batch_query_with_dicomweb_server( - page: Page, poll: Callable[[Locator], Locator], live_server: LiveServer, create_and_login_user -): +def test_urgent_batch_query_with_dicomweb_server(page: Page, live_server: LiveServer): # Arrange df = pd.DataFrame( [["1005", "0062115904"]], @@ -66,7 +64,7 @@ def test_urgent_batch_query_with_dicomweb_server( ) batch_file = create_excel_file(df, "batch_file.xlsx") - user: User = create_and_login_user(live_server.url) + user = create_and_login_example_user(page, live_server.url) group = create_batch_query_group() add_user_to_group(user, group) add_permission(group, BatchQueryJob, "can_process_urgently") @@ -87,4 +85,4 @@ def test_urgent_batch_query_with_dicomweb_server( run_worker_once() # Assert - expect(poll(page.locator('dl:has-text("Success")'))).to_be_visible() + expect(poll_locator(page.locator('dl:has-text("Success")'))).to_be_visible() diff --git a/adit/batch_query/utils/testing_helpers.py b/adit/batch_query/utils/testing_helpers.py index f8665641..45a2fc0d 100644 --- a/adit/batch_query/utils/testing_helpers.py +++ b/adit/batch_query/utils/testing_helpers.py @@ -1,5 +1,5 @@ from adit_radis_shared.accounts.factories import GroupFactory -from adit_radis_shared.common.utils.auth_utils import add_permission +from adit_radis_shared.common.utils.testing_helpers import add_permission def create_batch_query_group(): diff --git a/adit/batch_transfer/tests/integration/test_batch_transfer.py b/adit/batch_transfer/tests/integration/test_batch_transfer.py index 413dbfac..693d862c 100644 --- a/adit/batch_transfer/tests/integration/test_batch_transfer.py +++ b/adit/batch_transfer/tests/integration/test_batch_transfer.py @@ -1,11 +1,13 @@ -from typing import Callable - import pandas as pd import pytest -from adit_radis_shared.accounts.models import User -from adit_radis_shared.common.utils.auth_utils import add_permission, add_user_to_group -from adit_radis_shared.common.utils.worker_utils import run_worker_once -from playwright.sync_api import Locator, Page, expect +from adit_radis_shared.common.utils.testing_helpers import ( + add_permission, + add_user_to_group, + create_and_login_example_user, + poll_locator, + run_worker_once, +) +from playwright.sync_api import Page, expect from pytest_django.live_server_helper import LiveServer from adit.batch_transfer.models import BatchTransferJob @@ -21,7 +23,7 @@ @pytest.mark.integration @pytest.mark.django_db(transaction=True) def test_unpseudonymized_urgent_batch_transfer_with_dimse_server( - page: Page, poll: Callable[[Locator], Locator], live_server: LiveServer, create_and_login_user + page: Page, live_server: LiveServer ): # Arrange df = pd.DataFrame( @@ -30,7 +32,7 @@ def test_unpseudonymized_urgent_batch_transfer_with_dimse_server( ) batch_file = create_excel_file(df, "batch_file.xlsx") - user: User = create_and_login_user(live_server.url) + user = create_and_login_example_user(page, live_server.url) group = create_batch_transfer_group() add_user_to_group(user, group) add_permission(group, BatchTransferJob, "can_process_urgently") @@ -54,13 +56,13 @@ def test_unpseudonymized_urgent_batch_transfer_with_dimse_server( run_worker_once() # Assert - expect(poll(page.locator('dl:has-text("Success")'))).to_be_visible() + expect(poll_locator(page.locator('dl:has-text("Success")'))).to_be_visible() @pytest.mark.integration @pytest.mark.django_db(transaction=True) def test_unpseudonymized_urgent_batch_transfer_with_dicomweb_server( - page: Page, poll: Callable[[Locator], Locator], live_server: LiveServer, create_and_login_user + page: Page, live_server: LiveServer ): # Arrange df = pd.DataFrame( @@ -69,7 +71,7 @@ def test_unpseudonymized_urgent_batch_transfer_with_dicomweb_server( ) batch_file = create_excel_file(df, "batch_file.xlsx") - user: User = create_and_login_user(live_server.url) + user = create_and_login_example_user(page, live_server.url) group = create_batch_transfer_group() add_user_to_group(user, group) add_permission(group, BatchTransferJob, "can_process_urgently") @@ -93,4 +95,4 @@ def test_unpseudonymized_urgent_batch_transfer_with_dicomweb_server( run_worker_once() # Assert - expect(poll(page.locator('dl:has-text("Success")'))).to_be_visible() + expect(poll_locator(page.locator('dl:has-text("Success")'))).to_be_visible() diff --git a/adit/batch_transfer/tests/test_forms.py b/adit/batch_transfer/tests/test_forms.py index ad10a045..ce0342ba 100644 --- a/adit/batch_transfer/tests/test_forms.py +++ b/adit/batch_transfer/tests/test_forms.py @@ -1,6 +1,6 @@ import pytest from adit_radis_shared.accounts.factories import UserFactory -from adit_radis_shared.common.utils.auth_utils import add_user_to_group +from adit_radis_shared.common.utils.testing_helpers import add_user_to_group from django.core.files import File from pytest_mock import MockerFixture diff --git a/adit/batch_transfer/tests/test_views.py b/adit/batch_transfer/tests/test_views.py index 8c2e7a20..434f2654 100644 --- a/adit/batch_transfer/tests/test_views.py +++ b/adit/batch_transfer/tests/test_views.py @@ -1,6 +1,6 @@ import pytest from adit_radis_shared.accounts.factories import UserFactory -from adit_radis_shared.common.utils.auth_utils import add_user_to_group +from adit_radis_shared.common.utils.testing_helpers import add_user_to_group from django.conf import LazySettings from django.test import Client from django.urls import reverse diff --git a/adit/batch_transfer/utils/testing_helpers.py b/adit/batch_transfer/utils/testing_helpers.py index 4b4190bc..05ea66d4 100644 --- a/adit/batch_transfer/utils/testing_helpers.py +++ b/adit/batch_transfer/utils/testing_helpers.py @@ -3,7 +3,7 @@ import pandas as pd from adit_radis_shared.accounts.factories import GroupFactory -from adit_radis_shared.common.utils.auth_utils import add_permission +from adit_radis_shared.common.utils.testing_helpers import add_permission from django.core.files import File from django.core.files.uploadedfile import SimpleUploadedFile diff --git a/adit/core/tests/test_processors.py b/adit/core/tests/test_processors.py index 4444322c..70d6eb62 100644 --- a/adit/core/tests/test_processors.py +++ b/adit/core/tests/test_processors.py @@ -1,7 +1,7 @@ import pytest import time_machine from adit_radis_shared.accounts.factories import UserFactory -from adit_radis_shared.common.utils.auth_utils import add_user_to_group +from adit_radis_shared.common.utils.testing_helpers import add_user_to_group from pytest_mock import MockerFixture from adit.core.utils.testing_helpers import create_example_transfer_group, create_resources diff --git a/adit/core/tests/test_tasks.py b/adit/core/tests/test_tasks.py index 14488a87..cb62f0d4 100644 --- a/adit/core/tests/test_tasks.py +++ b/adit/core/tests/test_tasks.py @@ -1,5 +1,5 @@ import pytest -from adit_radis_shared.common.utils.worker_utils import run_worker_once +from adit_radis_shared.common.utils.testing_helpers import run_worker_once from pytest_mock import MockerFixture from adit.core.errors import RetriableDicomError diff --git a/adit/core/utils/testing_helpers.py b/adit/core/utils/testing_helpers.py index 90626df4..c9173992 100644 --- a/adit/core/utils/testing_helpers.py +++ b/adit/core/utils/testing_helpers.py @@ -5,7 +5,7 @@ import pandas as pd from adit_radis_shared.accounts.factories import GroupFactory -from adit_radis_shared.common.utils.auth_utils import add_permission +from adit_radis_shared.common.utils.testing_helpers import add_permission from dicomweb_client import DICOMwebClient from django.conf import settings from django.core.management import call_command diff --git a/adit/dicom_web/tests/integration/test_stowrs.py b/adit/dicom_web/tests/integration/test_stowrs.py index 0db4def7..ea0ed2cb 100644 --- a/adit/dicom_web/tests/integration/test_stowrs.py +++ b/adit/dicom_web/tests/integration/test_stowrs.py @@ -1,5 +1,5 @@ import pytest -from adit_radis_shared.common.utils.testing import ChannelsLiveServer +from adit_radis_shared.common.utils.testing_helpers import ChannelsLiveServer from pydicom import Dataset from pytest_django.live_server_helper import LiveServer diff --git a/adit/dicom_web/tests/integration/test_wadors.py b/adit/dicom_web/tests/integration/test_wadors.py index f26bdf03..94894770 100644 --- a/adit/dicom_web/tests/integration/test_wadors.py +++ b/adit/dicom_web/tests/integration/test_wadors.py @@ -1,6 +1,6 @@ import pydicom import pytest -from adit_radis_shared.common.utils.testing import ChannelsLiveServer +from adit_radis_shared.common.utils.testing_helpers import ChannelsLiveServer from adit.core.models import DicomServer from adit.core.utils.auth_utils import grant_access diff --git a/adit/dicom_web/utils/testing_helpers.py b/adit/dicom_web/utils/testing_helpers.py index 16e8310e..c56e7036 100644 --- a/adit/dicom_web/utils/testing_helpers.py +++ b/adit/dicom_web/utils/testing_helpers.py @@ -1,5 +1,5 @@ from adit_radis_shared.accounts.factories import GroupFactory, UserFactory -from adit_radis_shared.common.utils.auth_utils import add_permission, add_user_to_group +from adit_radis_shared.common.utils.testing_helpers import add_permission, add_user_to_group from adit_radis_shared.token_authentication.models import Token diff --git a/adit/selective_transfer/tests/integration/test_selective_transfer.py b/adit/selective_transfer/tests/integration/test_selective_transfer.py index 89038c89..f41dd5e5 100644 --- a/adit/selective_transfer/tests/integration/test_selective_transfer.py +++ b/adit/selective_transfer/tests/integration/test_selective_transfer.py @@ -1,8 +1,11 @@ import pytest -from adit_radis_shared.accounts.models import User -from adit_radis_shared.common.utils.auth_utils import add_permission, add_user_to_group -from adit_radis_shared.common.utils.testing import ChannelsLiveServer -from adit_radis_shared.common.utils.worker_utils import run_worker_once +from adit_radis_shared.common.utils.testing_helpers import ( + ChannelsLiveServer, + add_permission, + add_user_to_group, + create_and_login_example_user, + run_worker_once, +) from playwright.sync_api import Page, expect from adit.core.utils.auth_utils import grant_access @@ -14,10 +17,10 @@ @pytest.mark.integration @pytest.mark.django_db(transaction=True) def test_unpseudonymized_urgent_selective_transfer_with_dimse_server( - page: Page, channels_live_server: ChannelsLiveServer, create_and_login_user + page: Page, channels_live_server: ChannelsLiveServer ): # Arrange - user: User = create_and_login_user(channels_live_server.url) + user = create_and_login_example_user(page, channels_live_server.url) group = create_selective_transfer_group() add_user_to_group(user, group) add_permission(group, SelectiveTransferJob, "can_process_urgently") @@ -49,10 +52,10 @@ def test_unpseudonymized_urgent_selective_transfer_with_dimse_server( @pytest.mark.integration @pytest.mark.django_db(transaction=True) def test_unpseudonymized_urgent_selective_transfer_with_dicomweb_server( - page: Page, channels_live_server: ChannelsLiveServer, create_and_login_user + page: Page, channels_live_server: ChannelsLiveServer ): # Arrange - user: User = create_and_login_user(channels_live_server.url) + user = create_and_login_example_user(page, channels_live_server.url) group = create_selective_transfer_group() add_user_to_group(user, group) add_permission(group, SelectiveTransferJob, "can_process_urgently") diff --git a/adit/selective_transfer/utils/testing_helpers.py b/adit/selective_transfer/utils/testing_helpers.py index 14527dc3..e471fd7f 100644 --- a/adit/selective_transfer/utils/testing_helpers.py +++ b/adit/selective_transfer/utils/testing_helpers.py @@ -1,5 +1,5 @@ from adit_radis_shared.accounts.factories import GroupFactory -from adit_radis_shared.common.utils.auth_utils import add_permission +from adit_radis_shared.common.utils.testing_helpers import add_permission from django.contrib.auth.models import Group diff --git a/poetry.lock b/poetry.lock index d716a1ce..07f87d77 100644 --- a/poetry.lock +++ b/poetry.lock @@ -36,8 +36,8 @@ whitenoise = "^6.0.0" [package.source] type = "git" url = "https://github.com/openradx/adit-radis-shared.git" -reference = "0.10.1" -resolved_reference = "0fcaacb280bf3c68624d74529f4187ec7c3ece6c" +reference = "0.11.0" +resolved_reference = "c0615600a8bab511aa0ce22baa3e6ba11be0ad8d" [[package]] name = "adrf" @@ -3628,4 +3628,4 @@ testing = ["coverage[toml]", "zope.event", "zope.testing"] [metadata] lock-version = "2.0" python-versions = ">=3.12,<4.0" -content-hash = "401a8bb91290b9401c4df537fa7830b7265a32b11dc42620290bfb52673c181c" +content-hash = "8827db1da1634eac4f5c254bbc198fbdeac61cea337ff6f7a695d6b9ad581245" diff --git a/pyproject.toml b/pyproject.toml index 3e25ba68..8e57d66c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ license = "AGPL-3.0-or-later" readme = "README.md" [tool.poetry.dependencies] -adit-radis-shared = { git = "https://github.com/openradx/adit-radis-shared.git", tag = "0.10.1" } +adit-radis-shared = { git = "https://github.com/openradx/adit-radis-shared.git", tag = "0.11.0" } adrf = "^0.1.1" aiofiles = "^24.1.0" asyncinotify = "^4.0.1"