Example #1
0
def mock_read_settings_file(mock_settings_values, mock_settings_version):
    with patch("opentrons.config.advanced_settings._read_settings_file") as p:
        p.return_value = \
            advanced_settings.SettingsData(
                settings_map=mock_settings_values,
                version=mock_settings_version)
        yield p
Example #2
0
async def test_restart_required(loop, restore_restart_required,
                                mock_read_settings_file,
                                mock_write_settings_file,
                                mock_settings_version):
    _id = 'restart_required'
    # Mock out the available settings
    available_settings = [
        advanced_settings.SettingDefinition(_id=_id,
                                            title='',
                                            description='',
                                            restart_required=True)
    ]
    with patch.object(advanced_settings, "settings", new=available_settings):
        # Mock out the settings_by_id
        available_settings_by_id = {s.id: s for s in available_settings}
        with patch.object(advanced_settings,
                          "settings_by_id",
                          new=available_settings_by_id):
            mock_read_settings_file.return_value = \
                advanced_settings.SettingsData(
                    settings_map={_id: None},
                    version=mock_settings_version
                )

            assert advanced_settings.is_restart_required() is False
            await advanced_settings.set_adv_setting(_id, True)
            assert advanced_settings.is_restart_required() is True
Example #3
0
async def test_set_adv_setting_unknown(loop, mock_read_settings_file,
                                       mock_write_settings_file):
    mock_read_settings_file.return_value = \
        advanced_settings.SettingsData({}, 1)
    with pytest.raises(ValueError, match="is not recognized"):
        await advanced_settings.set_adv_setting("no", False)
Example #4
0
def test_get_all_adv_settings_empty(mock_read_settings_file):
    mock_read_settings_file.return_value = \
        advanced_settings.SettingsData({}, 1)
    s = advanced_settings.get_all_adv_settings()
    assert s == {}
Example #5
0
def mock_settings(mock_settings_values, mock_settings_version):
    return advanced_settings.SettingsData(settings_map=mock_settings_values,
                                          version=mock_settings_version)