Skip to content

Commit

Permalink
Use new run_worker_once utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
medihack committed Dec 25, 2024
1 parent 1f4c455 commit 6490ad1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
7 changes: 3 additions & 4 deletions adit/batch_query/tests/integration/test_batch_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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.batch_query.models import BatchQueryJob
Expand All @@ -16,7 +17,6 @@ def test_urgent_batch_query_with_dimse_server(
page: Page,
poll: Callable[[Locator], Locator],
dimse_orthancs,
run_worker,
live_server,
create_and_login_user,
batch_query_group,
Expand Down Expand Up @@ -44,7 +44,7 @@ def test_urgent_batch_query_with_dimse_server(
page.get_by_label("Batch file*", exact=True).set_input_files(files=[batch_file])
page.locator('input:has-text("Create job")').click()

run_worker()
run_worker_once()

# Assert
expect(poll(page.locator('dl:has-text("Success")'))).to_be_visible()
Expand All @@ -56,7 +56,6 @@ def test_urgent_batch_query_with_dicomweb_server(
page: Page,
poll: Callable[[Locator], Locator],
dicomweb_orthancs,
run_worker,
live_server,
create_and_login_user,
batch_query_group,
Expand Down Expand Up @@ -84,7 +83,7 @@ def test_urgent_batch_query_with_dicomweb_server(
page.get_by_label("Batch file*", exact=True).set_input_files(files=[batch_file])
page.locator('input:has-text("Create job")').click()

run_worker()
run_worker_once()

# Assert
expect(poll(page.locator('dl:has-text("Success")'))).to_be_visible()
7 changes: 3 additions & 4 deletions adit/batch_transfer/tests/integration/test_batch_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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.batch_transfer.models import BatchTransferJob
Expand All @@ -16,7 +17,6 @@ def test_unpseudonymized_urgent_batch_transfer_with_dimse_server(
page: Page,
poll: Callable[[Locator], Locator],
dimse_orthancs,
run_worker,
live_server,
create_and_login_user,
batch_transfer_group,
Expand Down Expand Up @@ -47,7 +47,7 @@ def test_unpseudonymized_urgent_batch_transfer_with_dimse_server(
page.get_by_label("Batch file*", exact=True).set_input_files(files=[batch_file])
page.locator('input:has-text("Create job")').click()

run_worker()
run_worker_once()

# Assert
expect(poll(page.locator('dl:has-text("Success")'))).to_be_visible()
Expand All @@ -59,7 +59,6 @@ def test_unpseudonymized_urgent_batch_transfer_with_dicomweb_server(
page: Page,
poll: Callable[[Locator], Locator],
dicomweb_orthancs,
run_worker,
live_server,
create_and_login_user,
batch_transfer_group,
Expand Down Expand Up @@ -90,7 +89,7 @@ def test_unpseudonymized_urgent_batch_transfer_with_dicomweb_server(
page.get_by_label("Batch file*", exact=True).set_input_files(files=[batch_file])
page.locator('input:has-text("Create job")').click()

run_worker()
run_worker_once()

# Assert
expect(poll(page.locator('dl:has-text("Success")'))).to_be_visible()
17 changes: 9 additions & 8 deletions adit/core/tests/test_tasks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from adit_radis_shared.common.utils.worker_utils import run_worker_once
from pytest_mock import MockerFixture

from adit.core.errors import RetriableDicomError
Expand Down Expand Up @@ -29,7 +30,7 @@ def patch_dicom_processors(mocker: MockerFixture):


@pytest.mark.django_db(transaction=True)
def test_process_dicom_task_that_succeeds(mocker: MockerFixture, run_worker):
def test_process_dicom_task_that_succeeds(mocker: MockerFixture):
dicom_job = ExampleTransferJobFactory.create(status=DicomJob.Status.PENDING)
dicom_task = ExampleTransferTaskFactory.create(
status=DicomTask.Status.PENDING,
Expand All @@ -50,7 +51,7 @@ def process(self):

mocker.patch.object(ExampleProcessor, "process", process)

run_worker()
run_worker_once()

dicom_job.refresh_from_db()
assert dicom_job.status == DicomJob.Status.SUCCESS
Expand All @@ -63,7 +64,7 @@ def process(self):


@pytest.mark.django_db(transaction=True)
def test_process_dicom_task_that_fails(mocker: MockerFixture, run_worker):
def test_process_dicom_task_that_fails(mocker: MockerFixture):
dicom_job = ExampleTransferJobFactory.create(status=DicomJob.Status.PENDING)
dicom_task = ExampleTransferTaskFactory.create(
status=DicomTask.Status.PENDING,
Expand All @@ -84,7 +85,7 @@ def process(self):

mocker.patch.object(ExampleProcessor, "process", process)

run_worker()
run_worker_once()

dicom_job.refresh_from_db()
assert dicom_job.status == DicomJob.Status.FAILURE
Expand All @@ -97,7 +98,7 @@ def process(self):


@pytest.mark.django_db(transaction=True)
def test_process_dicom_task_that_should_be_retried(mocker: MockerFixture, run_worker):
def test_process_dicom_task_that_should_be_retried(mocker: MockerFixture):
dicom_job = ExampleTransferJobFactory.create(status=DicomJob.Status.PENDING)
dicom_task = ExampleTransferTaskFactory.create(
status=DicomTask.Status.PENDING,
Expand All @@ -114,7 +115,7 @@ def process(self):

mocker.patch.object(ExampleProcessor, "process", process)

run_worker()
run_worker_once()

dicom_job.refresh_from_db()
assert dicom_job.status == DicomJob.Status.PENDING
Expand All @@ -127,7 +128,7 @@ def process(self):


@pytest.mark.django_db(transaction=True)
def test_process_dicom_task_that_raises(mocker: MockerFixture, run_worker):
def test_process_dicom_task_that_raises(mocker: MockerFixture):
dicom_job = ExampleTransferJobFactory.create(status=DicomJob.Status.PENDING)
dicom_task = ExampleTransferTaskFactory.create(
status=DicomTask.Status.PENDING,
Expand All @@ -144,7 +145,7 @@ def process(self):

mocker.patch.object(ExampleProcessor, "process", process)

run_worker()
run_worker_once()

dicom_job.refresh_from_db()
assert dicom_job.status == DicomJob.Status.FAILURE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Callable

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 playwright.sync_api import Locator, Page, expect
from adit_radis_shared.common.utils.worker_utils import run_worker_once
from playwright.sync_api import Page, expect

from adit.core.utils.auth_utils import grant_access
from adit.selective_transfer.models import SelectiveTransferJob
Expand All @@ -13,9 +12,7 @@
@pytest.mark.django_db(transaction=True)
def test_unpseudonymized_urgent_selective_transfer_with_dimse_server(
page: Page,
poll: Callable[[Locator], Locator],
dimse_orthancs,
run_worker,
channels_live_server,
create_and_login_user,
selective_transfer_group,
Expand All @@ -33,24 +30,25 @@ def test_unpseudonymized_urgent_selective_transfer_with_dimse_server(
page.get_by_label("Urgent").click(force=True)
page.get_by_label("Source").select_option(label="DICOM Server Orthanc Test Server 1")
page.get_by_label("Destination").select_option(label="DICOM Server Orthanc Test Server 2")
page.get_by_label("Patient ID").click()
page.get_by_label("Patient ID").fill("1008")
page.get_by_label("Patient ID").press("Enter")
page.locator('tr:has-text("1008"):has-text("2020") input').click()
page.locator('button:has-text("Start transfer")').click()
page.locator('a:has-text("ID")').click()

run_worker()
run_worker_once()
page.reload()

# Assert
expect(poll(page.locator('dl:has-text("Success")'))).to_be_visible()
expect(page.locator('dl:has-text("Success")')).to_be_visible()


@pytest.mark.integration
@pytest.mark.django_db(transaction=True)
def test_unpseudonymized_urgent_selective_transfer_with_dicomweb_server(
page: Page,
poll: Callable[[Locator], Locator],
dicomweb_orthancs,
run_worker,
channels_live_server,
create_and_login_user,
selective_transfer_group,
Expand All @@ -68,12 +66,15 @@ def test_unpseudonymized_urgent_selective_transfer_with_dicomweb_server(
page.get_by_label("Urgent").click(force=True)
page.get_by_label("Source").select_option(label="DICOM Server Orthanc Test Server 1")
page.get_by_label("Destination").select_option(label="DICOM Server Orthanc Test Server 2")
page.get_by_label("Patient ID").click()
page.get_by_label("Patient ID").fill("1008")
page.get_by_label("Patient ID").press("Enter")
page.locator('tr:has-text("1008"):has-text("2020") input').click()
page.locator('button:has-text("Start transfer")').click()
page.locator('a:has-text("ID")').click()

run_worker()
run_worker_once()
page.reload()

# Assert
expect(poll(page.locator('dl:has-text("Success")'))).to_be_visible()
expect(page.locator('dl:has-text("Success")')).to_be_visible()
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.9.6" }
adit-radis-shared = { git = "https://github.com/openradx/adit-radis-shared.git", tag = "0.10.1" }
adrf = "^0.1.1"
aiofiles = "^24.1.0"
asyncinotify = "^4.0.1"
Expand Down

0 comments on commit 6490ad1

Please sign in to comment.