Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix settings tests #14810

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/src/opentrons/config/advanced_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class Setting(NamedTuple):
),
robot_type=[RobotTypeEnum.OT2, RobotTypeEnum.FLEX],
internal_only=True,
)
),
]

if (
Expand Down Expand Up @@ -719,6 +719,7 @@ def _migrate31to32(previous: SettingsMap) -> SettingsMap:
newmap["enableOEMMode"] = None
return newmap


def _migrate32to33(previous: SettingsMap) -> SettingsMap:
"""Migrate to version 33 of the feature flags file.

Expand Down
4 changes: 1 addition & 3 deletions api/src/opentrons/config/feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,4 @@ def enable_error_recovery_experiments() -> bool:


def enable_performance_metrics(robot_type: RobotTypeEnum) -> bool:
return advs.get_setting_with_env_overload(
"enablePerformanceMetrics", robot_type
)
return advs.get_setting_with_env_overload("enablePerformanceMetrics", robot_type)
23 changes: 16 additions & 7 deletions api/tests/opentrons/config/test_advanced_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ def mock_settings_values_flex() -> Dict[str, Optional[bool]]:
}


@pytest.fixture
def mock_settings_values_flex_all() -> Dict[str, Optional[bool]]:
return {
s.id: False
for s in advanced_settings.settings
if RobotTypeEnum.FLEX in s.robot_type
}


@pytest.fixture
def mock_settings_values_empty() -> Dict[str, Optional[bool]]:
return {s.id: None for s in advanced_settings.settings}
Expand All @@ -57,25 +66,25 @@ def mock_settings(

@pytest.fixture
def mock_read_settings_file_ot2(
mock_settings_values_ot2: Dict[str, Optional[bool]],
mock_settings_values_ot2_all: Dict[str, Optional[bool]],
mock_settings_version: int,
) -> Generator[MagicMock, None, None]:
with patch("opentrons.config.advanced_settings._read_settings_file") as p:
p.return_value = advanced_settings.SettingsData(
settings_map=mock_settings_values_ot2,
settings_map=mock_settings_values_ot2_all,
version=mock_settings_version,
)
yield p


@pytest.fixture
def mock_read_settings_file_flex(
mock_settings_values_flex: Dict[str, Optional[bool]],
mock_settings_values_flex_all: Dict[str, Optional[bool]],
mock_settings_version: int,
) -> Generator[MagicMock, None, None]:
with patch("opentrons.config.advanced_settings._read_settings_file") as p:
p.return_value = advanced_settings.SettingsData(
settings_map=mock_settings_values_flex,
settings_map=mock_settings_values_flex_all,
version=mock_settings_version,
)
yield p
Expand Down Expand Up @@ -168,19 +177,19 @@ def test_get_all_adv_settings_empty(

async def test_set_adv_setting(
mock_read_settings_file_ot2: MagicMock,
mock_settings_values_ot2: MagicMock,
mock_settings_values_ot2_all: MagicMock,
mock_write_settings_file: MagicMock,
mock_settings_version: int,
restore_restart_required: None,
) -> None:
for k, v in mock_settings_values_ot2.items():
for k, v in mock_settings_values_ot2_all.items():
# Toggle the advanced setting
await advanced_settings.set_adv_setting(k, not v)
mock_write_settings_file.assert_called_with(
# Only the current key is toggled
{
nk: nv if nk != k else not v
for nk, nv in mock_settings_values_ot2.items()
for nk, nv in mock_settings_values_ot2_all.items()
},
mock_settings_version,
CONFIG["feature_flags_file"],
Expand Down
Loading