Skip to content

Commit 8a9032b

Browse files
committed
Added test for the new 'register_lamella_evaluation_image' API endpoint
1 parent 9c31012 commit 8a9032b

1 file changed

Lines changed: 56 additions & 2 deletions

File tree

tests/server/api/test_workflow_fib.py

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
from pytest_mock import MockerFixture
66

77
from murfey.server.api.workflow_fib import (
8-
FIBAtlasFile,
8+
File,
99
make_gif,
1010
register_fib_atlas,
11+
register_lamella_evaluation_image,
1112
)
1213
from murfey.util.models import FIBGIFParameters
1314

@@ -26,7 +27,7 @@ def test_register_fib_atlas(
2627
):
2728
# Set up the variables
2829
session_id = 1
29-
fib_atlas = FIBAtlasFile(**{"file": str(tmp_path / "dummy")})
30+
fib_atlas = File(**{"file": str(tmp_path / "dummy")})
3031

3132
# Mock the logger
3233
mock_logger = mocker.patch("murfey.server.api.workflow_fib.logger")
@@ -65,6 +66,59 @@ def test_register_fib_atlas(
6566
mock_logger.error.assert_called_with("No TransportManager object was set up")
6667

6768

69+
@pytest.mark.parametrize(
70+
"has_transport_object",
71+
(
72+
True,
73+
False,
74+
),
75+
)
76+
def test_register_lamella_evaluation_image(
77+
mocker: MockerFixture,
78+
tmp_path: Path,
79+
has_transport_object: bool,
80+
):
81+
# Set up the variables
82+
session_id = 1
83+
lamella_image = File(**{"file": str(tmp_path / "dummy")})
84+
85+
# Mock the logger
86+
mock_logger = mocker.patch("murfey.server.api.workflow_fib.logger")
87+
88+
# Mock the transport object
89+
if has_transport_object:
90+
mock_transport_object = MagicMock()
91+
mock_transport_object.feedback_queue = "dummy"
92+
mocker.patch(
93+
"murfey.server.api.workflow_fib._transport_object",
94+
mock_transport_object,
95+
)
96+
else:
97+
mocker.patch(
98+
"murfey.server.api.workflow_fib._transport_object",
99+
None,
100+
)
101+
102+
# Run the function and check that the expected calls were made
103+
register_lamella_evaluation_image(
104+
session_id=session_id,
105+
lamella_image=lamella_image,
106+
)
107+
108+
# Check that the expected calls were made
109+
if has_transport_object:
110+
mock_transport_object.send.assert_called_with(
111+
"dummy",
112+
{
113+
"register": "fib.register_lamella_evaluation_image",
114+
"session_id": session_id,
115+
"lamella_image_file": str(lamella_image.file),
116+
},
117+
)
118+
else:
119+
mock_logger.error.assert_called_with("No TransportManager object was set up")
120+
121+
68122
@pytest.mark.parametrize(
69123
"has_transport_object",
70124
(

0 commit comments

Comments
 (0)