Skip to content

Commit

Permalink
Mock path provider for configured plan
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Nov 14, 2024
1 parent 7fdae64 commit 7063c1a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/unit_tests/worker/test_task_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import threading
from collections.abc import Callable, Iterable
from concurrent.futures import Future
from pathlib import Path
from queue import Full
from typing import Any, TypeVar
from unittest.mock import ANY, MagicMock, patch

import pytest
from dodal.common.types import UpdatingPathProvider
from observability_utils.tracing import (
JsonObjectSpanExporter,
asserting_span_exporter,
Expand Down Expand Up @@ -341,7 +343,18 @@ def begin_task_and_wait_until_complete(
#


def test_worker_and_data_events_produce_in_order(worker: TaskWorker) -> None:
@pytest.fixture
def path_provider(tmp_path: Path):
# Prevents issue with leftover state from beamline tests
with patch("dodal.plan_stubs.data_session.get_path_provider") as mock:
mock.return_value = MagicMock(spec=UpdatingPathProvider, return_value=tmp_path)
mock.return_value.data_session.return_value = "foo"
yield


def test_worker_and_data_events_produce_in_order(
worker: TaskWorker, path_provider
) -> None:
assert_running_count_plan_produces_ordered_worker_and_data_events(
[
WorkerEvent(
Expand Down

0 comments on commit 7063c1a

Please sign in to comment.