Skip to content

Commit

Permalink
test(snapshot): default doesnt match choice
Browse files Browse the repository at this point in the history
  • Loading branch information
y3rsh committed Apr 8, 2024
1 parent 3995476 commit 17c4380
Show file tree
Hide file tree
Showing 7 changed files with 304 additions and 4 deletions.
4 changes: 4 additions & 0 deletions app-testing/automation/data/protocol_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,8 @@
"v2_18_NO_PIPETTES_Overrides_DefaultOutOfRangeRTP",
"v2_18_NO_PIPETTES_Overrides_DefaultOutOfRangeRTP_Override_default_less_than_minimum",
"v2_18_NO_PIPETTES_Overrides_DefaultOutOfRangeRTP_Override_default_greater_than_maximum",
"v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice",
"v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice_Override_str_default_no_matching_choices",
"v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice_Override_float_default_no_matching_choices",
"v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice_Override_int_default_no_matching_choices",
]
20 changes: 16 additions & 4 deletions app-testing/automation/data/protocols_with_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class ProtocolsWithOverrides:
file_extension="py",
protocol_name="Golden RTP Examples 2",
robot="Flex",
app_error=False,
robot_error=False,
app_error=True,
robot_error=True,
override_variable_name="type_to_test",
overrides=[
"wrong_type_in_display_name",
Expand All @@ -30,12 +30,24 @@ class ProtocolsWithOverrides:
file_extension="py",
protocol_name="Default not in range",
robot="Flex",
app_error=False,
robot_error=False,
app_error=True,
robot_error=True,
override_variable_name="type_to_test",
overrides=[
"default_greater_than_maximum",
"default_less_than_minimum",
],
category=ProtocolCategory(robot="Flex", outcome="Error"),
)

v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice: ProtocolWithOverrides = ProtocolWithOverrides(
file_stem="v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice",
file_extension="py",
protocol_name="default choice does not match a choice",
robot="Flex",
app_error=True,
robot_error=True,
override_variable_name="type_to_test",
overrides=["str_default_no_matching_choices", "float_default_no_matching_choices", "int_default_no_matching_choices"],
category=ProtocolCategory(robot="Flex", outcome="Error"),
)
1 change: 1 addition & 0 deletions app-testing/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ v8_P1000_96_HS_GRIP_TC_TM_GripperCollisionWithTips

APP_ANALYSIS_TEST_PROTOCOLS_WITH_OVERRIDES="
v2_18_NO_PIPETTES_Overrides_BadTypesInRTP,
v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice,
v2_18_NO_PIPETTES_Overrides_DefaultOutOfRangeRTP
"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# I am going to get added to in the test runner
# type_to_test = wrong_type_in_display_name
# protocol.override_variable_name = type_to_test

metadata = {
"protocolName": "default choice does not match a choice",
}

requirements = {"robotType": "Flex", "apiLevel": "2.18"}


# change me to test that a bad type is caught
# for each field of parameter.
# protocol.overrides is a list of these strings
str_default_no_matching_choices = "str_default_no_matching_choices"
float_default_no_matching_choices = "float_default_no_matching_choices"
int_default_no_matching_choices = "int_default_no_matching_choices"


def add_parameters(parameters):
match type_to_test:
case str() if type_to_test == int_default_no_matching_choices:
parameters.add_int(
display_name="Mixing Volume in µL",
variable_name="mix_in_volume",
default=10,
choices=[
{"display_name": "Low Volume ⬇️", "value": 9},
{"display_name": "Medium Volume 🟰", "value": 15},
{"display_name": "High Volume ⬆️", "value": 20},
],
description="This is a description.",
)
case str() if type_to_test == float_default_no_matching_choices:
parameters.add_float(
display_name="Mixing Volume in µL",
variable_name="mix_in_volume",
default=150.0,
choices=[
{"display_name": "Low Volume ⬇️", "value": 100.0},
{"display_name": "Medium Volume 🟰", "value": 160.0},
{"display_name": "High Volume ⬆️", "value": 200.0},
],
description="This is a description.",
)
case str() if type_to_test == str_default_no_matching_choices:
parameters.add_str(
display_name="Pipette Name",
variable_name="pipette",
choices=[
{"display_name": "1channel", "value": "flex_1channel_50"},
{"display_name": "Eight Channel 50µL", "value": "flex_8channel_50"},
],
default="I am not in the choices",
description="This is a description.",
)


def run(context):
for variable_name, value in context.params.get_all().items():
context.comment(f"variable {variable_name} has value {value}")
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"commands": [
{
"commandType": "home",
"notes": [],
"params": {},
"result": {},
"status": "succeeded"
}
],
"config": {
"apiVersion": [
2,
18
],
"protocolType": "python"
},
"errors": [
{
"detail": "ParameterValueError [line 36]: Parameter must be set to one of the allowed values of {160.0, 100.0, 200.0}.",
"errorCode": "4000",
"errorInfo": {},
"errorType": "ExceptionInProtocolError",
"wrappedErrors": [
{
"detail": "opentrons.protocols.parameters.types.ParameterValueError: Parameter must be set to one of the allowed values of {160.0, 100.0, 200.0}.",
"errorCode": "4000",
"errorInfo": {
"args": "('Parameter must be set to one of the allowed values of {160.0, 100.0, 200.0}.',)",
"class": "ParameterValueError",
"traceback": " File \"/usr/local/lib/python3.10/site-packages/opentrons/protocols/execution/execute_python.py\", line 80, in _parse_and_set_parameters\n exec(\"add_parameters(__param_context)\", new_globs)\n\n File \"<string>\", line 1, in <module>\n\n File \"v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice_Override_float_default_no_matching_choices.py\", line 36, in add_parameters\n\n File \"/usr/local/lib/python3.10/site-packages/opentrons/protocol_api/_parameter_context.py\", line 91, in add_float\n parameter = parameter_definition.create_float_parameter(\n\n File \"/usr/local/lib/python3.10/site-packages/opentrons/protocols/parameters/parameter_definition.py\", line 202, in create_float_parameter\n return ParameterDefinition(\n\n File \"/usr/local/lib/python3.10/site-packages/opentrons/protocols/parameters/parameter_definition.py\", line 84, in __init__\n self.value: ParamType = default\n\n File \"/usr/local/lib/python3.10/site-packages/opentrons/protocols/parameters/parameter_definition.py\", line 95, in value\n raise ParameterValueError(\n"
},
"errorType": "PythonException",
"wrappedErrors": []
}
]
}
],
"files": [
{
"name": "cpx_4_tuberack_100ul.json",
"role": "labware"
},
{
"name": "opentrons_ot3_96_tiprack_1000ul_rss.json",
"role": "labware"
},
{
"name": "opentrons_ot3_96_tiprack_200ul_rss.json",
"role": "labware"
},
{
"name": "opentrons_ot3_96_tiprack_50ul_rss.json",
"role": "labware"
},
{
"name": "sample_labware.json",
"role": "labware"
},
{
"name": "v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice_Override_float_default_no_matching_choices.py",
"role": "main"
}
],
"labware": [],
"liquids": [],
"metadata": {
"protocolName": "default choice does not match a choice"
},
"modules": [],
"pipettes": [],
"robotType": "OT-3 Standard",
"runTimeParameters": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"commands": [
{
"commandType": "home",
"notes": [],
"params": {},
"result": {},
"status": "succeeded"
}
],
"config": {
"apiVersion": [
2,
18
],
"protocolType": "python"
},
"errors": [
{
"detail": "ParameterValueError [line 48]: Parameter must be set to one of the allowed values of {'flex_8channel_50', 'flex_1channel_50'}.",
"errorCode": "4000",
"errorInfo": {},
"errorType": "ExceptionInProtocolError",
"wrappedErrors": [
{
"detail": "opentrons.protocols.parameters.types.ParameterValueError: Parameter must be set to one of the allowed values of {'flex_8channel_50', 'flex_1channel_50'}.",
"errorCode": "4000",
"errorInfo": {
"args": "(\"Parameter must be set to one of the allowed values of {'flex_8channel_50', 'flex_1channel_50'}.\",)",
"class": "ParameterValueError",
"traceback": " File \"/usr/local/lib/python3.10/site-packages/opentrons/protocols/execution/execute_python.py\", line 80, in _parse_and_set_parameters\n exec(\"add_parameters(__param_context)\", new_globs)\n\n File \"<string>\", line 1, in <module>\n\n File \"v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice_Override_str_default_no_matching_choices.py\", line 48, in add_parameters\n\n File \"/usr/local/lib/python3.10/site-packages/opentrons/protocol_api/_parameter_context.py\", line 148, in add_str\n parameter = parameter_definition.create_str_parameter(\n\n File \"/usr/local/lib/python3.10/site-packages/opentrons/protocols/parameters/parameter_definition.py\", line 241, in create_str_parameter\n return ParameterDefinition(\n\n File \"/usr/local/lib/python3.10/site-packages/opentrons/protocols/parameters/parameter_definition.py\", line 84, in __init__\n self.value: ParamType = default\n\n File \"/usr/local/lib/python3.10/site-packages/opentrons/protocols/parameters/parameter_definition.py\", line 95, in value\n raise ParameterValueError(\n"
},
"errorType": "PythonException",
"wrappedErrors": []
}
]
}
],
"files": [
{
"name": "cpx_4_tuberack_100ul.json",
"role": "labware"
},
{
"name": "opentrons_ot3_96_tiprack_1000ul_rss.json",
"role": "labware"
},
{
"name": "opentrons_ot3_96_tiprack_200ul_rss.json",
"role": "labware"
},
{
"name": "opentrons_ot3_96_tiprack_50ul_rss.json",
"role": "labware"
},
{
"name": "sample_labware.json",
"role": "labware"
},
{
"name": "v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice_Override_str_default_no_matching_choices.py",
"role": "main"
}
],
"labware": [],
"liquids": [],
"metadata": {
"protocolName": "default choice does not match a choice"
},
"modules": [],
"pipettes": [],
"robotType": "OT-3 Standard",
"runTimeParameters": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"commands": [
{
"commandType": "home",
"notes": [],
"params": {},
"result": {},
"status": "succeeded"
}
],
"config": {
"apiVersion": [
2,
18
],
"protocolType": "python"
},
"errors": [
{
"detail": "ParameterValueError [line 24]: Parameter must be set to one of the allowed values of {9, 20, 15}.",
"errorCode": "4000",
"errorInfo": {},
"errorType": "ExceptionInProtocolError",
"wrappedErrors": [
{
"detail": "opentrons.protocols.parameters.types.ParameterValueError: Parameter must be set to one of the allowed values of {9, 20, 15}.",
"errorCode": "4000",
"errorInfo": {
"args": "('Parameter must be set to one of the allowed values of {9, 20, 15}.',)",
"class": "ParameterValueError",
"traceback": " File \"/usr/local/lib/python3.10/site-packages/opentrons/protocols/execution/execute_python.py\", line 80, in _parse_and_set_parameters\n exec(\"add_parameters(__param_context)\", new_globs)\n\n File \"<string>\", line 1, in <module>\n\n File \"v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice_Override_int_default_no_matching_choices.py\", line 24, in add_parameters\n\n File \"/usr/local/lib/python3.10/site-packages/opentrons/protocol_api/_parameter_context.py\", line 55, in add_int\n parameter = parameter_definition.create_int_parameter(\n\n File \"/usr/local/lib/python3.10/site-packages/opentrons/protocols/parameters/parameter_definition.py\", line 178, in create_int_parameter\n return ParameterDefinition(\n\n File \"/usr/local/lib/python3.10/site-packages/opentrons/protocols/parameters/parameter_definition.py\", line 84, in __init__\n self.value: ParamType = default\n\n File \"/usr/local/lib/python3.10/site-packages/opentrons/protocols/parameters/parameter_definition.py\", line 95, in value\n raise ParameterValueError(\n"
},
"errorType": "PythonException",
"wrappedErrors": []
}
]
}
],
"files": [
{
"name": "cpx_4_tuberack_100ul.json",
"role": "labware"
},
{
"name": "opentrons_ot3_96_tiprack_1000ul_rss.json",
"role": "labware"
},
{
"name": "opentrons_ot3_96_tiprack_200ul_rss.json",
"role": "labware"
},
{
"name": "opentrons_ot3_96_tiprack_50ul_rss.json",
"role": "labware"
},
{
"name": "sample_labware.json",
"role": "labware"
},
{
"name": "v2_18_NO_PIPETTES_Overrides_DefaultChoiceNoMatchChoice_Override_int_default_no_matching_choices.py",
"role": "main"
}
],
"labware": [],
"liquids": [],
"metadata": {
"protocolName": "default choice does not match a choice"
},
"modules": [],
"pipettes": [],
"robotType": "OT-3 Standard",
"runTimeParameters": []
}

0 comments on commit 17c4380

Please sign in to comment.