-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f996ae
commit 949cfd0
Showing
3 changed files
with
85 additions
and
81 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
...-data-generation/src/test_data_generation/deck_configuration/strategy/final_strategies.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
"""Test data generation for deck configuration tests.""" | ||
from hypothesis import assume, strategies as st | ||
from test_data_generation.deck_configuration.datashapes import ( | ||
Column, | ||
DeckConfiguration, | ||
Slot, | ||
PossibleSlotContents as PSC, | ||
) | ||
|
||
from test_data_generation.deck_configuration.strategy.helper_strategies import a_column | ||
|
||
|
||
def _above_or_below_is_module_or_trash(col: Column, slot: Slot) -> bool: | ||
"""Return True if the deck has a module above or below the specified slot.""" | ||
above = col.slot_above(slot) | ||
below = col.slot_below(slot) | ||
|
||
return (above is not None and above.contents.is_module_or_trash_bin()) or ( | ||
below is not None and below.contents.is_module_or_trash_bin() | ||
) | ||
|
||
|
||
@st.composite | ||
def a_deck_configuration_with_a_module_or_trash_slot_above_or_below_a_heater_shaker( | ||
draw: st.DrawFn, | ||
) -> DeckConfiguration: | ||
"""Generate a deck with a module or trash bin fixture above or below a heater shaker.""" | ||
deck = draw( | ||
st.builds( | ||
DeckConfiguration.from_cols, | ||
col1=a_column("1"), | ||
col2=a_column( | ||
"2", content_options=[PSC.LABWARE_SLOT, PSC.MAGNETIC_BLOCK_MODULE] | ||
), | ||
col3=a_column("3"), | ||
) | ||
) | ||
column = deck.column_by_number(draw(st.sampled_from(["1", "3"]))) | ||
|
||
assume(column.number_of(PSC.HEATER_SHAKER_MODULE) in [1, 2]) | ||
for slot in column.slots: | ||
if slot.contents is PSC.HEATER_SHAKER_MODULE: | ||
assume(_above_or_below_is_module_or_trash(column, slot)) | ||
deck.override_with_column(column) | ||
|
||
return deck | ||
|
||
|
||
@st.composite | ||
def a_deck_configuration_with_invalid_fixture_in_col_2( | ||
draw: st.DrawFn, | ||
) -> DeckConfiguration: | ||
"""Generate a deck with an invalid fixture in column 2.""" | ||
POSSIBLE_FIXTURES = [ | ||
PSC.LABWARE_SLOT, | ||
PSC.TEMPERATURE_MODULE, | ||
PSC.HEATER_SHAKER_MODULE, | ||
PSC.TRASH_BIN, | ||
PSC.MAGNETIC_BLOCK_MODULE, | ||
] | ||
INVALID_FIXTURES = [ | ||
PSC.HEATER_SHAKER_MODULE, | ||
PSC.TRASH_BIN, | ||
PSC.TEMPERATURE_MODULE, | ||
] | ||
column2 = draw(a_column("2", content_options=POSSIBLE_FIXTURES)) | ||
num_invalid_fixtures = len( | ||
[True for slot in column2.slots if slot.contents.is_one_of(INVALID_FIXTURES)] | ||
) | ||
assume(num_invalid_fixtures > 0) | ||
|
||
deck = draw( | ||
st.builds( | ||
DeckConfiguration.from_cols, | ||
col1=a_column("1"), | ||
col2=st.just(column2), | ||
col3=a_column("3"), | ||
) | ||
) | ||
|
||
return deck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters