Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vegano1 committed Nov 1, 2024
1 parent 6fc53da commit 04b0cc8
Showing 1 changed file with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,67 +69,75 @@ def test_initialize(
) -> None:
"""It should set the sample wavelength with the engine client."""
subject._ready_to_initialize = True
subject.initialize("single", [123])
subject.initialize("single", [350])

decoy.verify(
mock_engine_client.execute_command(
cmd.absorbance_reader.InitializeParams(
moduleId="1234",
measureMode="single",
sampleWavelengths=[123],
sampleWavelengths=[350],
referenceWavelength=None,
),
),
times=1,
)
assert subject._initialized_value == [123]
assert subject._initialized_value == [350]

# Test reference wavelength
subject.initialize("single", [124], 450)
subject.initialize("single", [350], 450)

decoy.verify(
mock_engine_client.execute_command(
cmd.absorbance_reader.InitializeParams(
moduleId="1234",
measureMode="single",
sampleWavelengths=[124],
sampleWavelengths=[350],
referenceWavelength=450,
),
),
times=1,
)
assert subject._initialized_value == [124]
assert subject._initialized_value == [250]

# Test initialize multi
subject.initialize("multi", [124, 125, 126])
subject.initialize("multi", [350, 400, 450])

decoy.verify(
mock_engine_client.execute_command(
cmd.absorbance_reader.InitializeParams(
moduleId="1234",
measureMode="multi",
sampleWavelengths=[124, 125, 126],
sampleWavelengths=[350, 400, 450],
referenceWavelength=None,
),
),
times=1,
)
assert subject._initialized_value == [124, 125, 126]
assert subject._initialized_value == [350, 400, 450]


def test_initialize_not_ready(subject: AbsorbanceReaderCore) -> None:
"""It should raise CannotPerformModuleAction if you dont call .close_lid() command."""
subject._ready_to_initialize = False
with pytest.raises(CannotPerformModuleAction):
subject.initialize("single", [123])
subject.initialize("single", [350])


@pytest.mark.parametrize("wavelength", [-350, 0, 1200, "wda"])
def test_invalid_wavelengths(wavelength: int, subject: AbsorbanceReaderCore) -> None:
"""It should raise ValueError if you provide an invalid wavelength"""
subject._ready_to_initialize = True
with pytest.raises(ValueError):
subject.initialize("single", [wavelength])


def test_read(
decoy: Decoy, mock_engine_client: EngineClient, subject: AbsorbanceReaderCore
) -> None:
"""It should call absorbance reader to read with the engine client."""
subject._ready_to_initialize = True
subject._initialized_value = [123]
subject._initialized_value = [350]
substate = AbsorbanceReaderSubState(
module_id=AbsorbanceReaderId(subject.module_id),
configured=True,
Expand All @@ -152,6 +160,7 @@ def test_read(
mock_engine_client.execute_command(
cmd.absorbance_reader.ReadAbsorbanceParams(
moduleId="1234",
fileName=None,
),
),
times=1,
Expand Down

0 comments on commit 04b0cc8

Please sign in to comment.