예제 #1
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
예제 #2
0
def _create_settings_response() -> AdvancedSettingsResponse:
    """Create the feature flag settings response object"""
    data = advanced_settings.get_all_adv_settings()

    if advanced_settings.is_restart_required():
        links = Links(restart='/server/restart')
    else:
        links = Links()

    return AdvancedSettingsResponse(
        links=links,
        settings=[
            AdvancedSetting(id=s.definition.id,
                            old_id=s.definition.old_id,
                            title=s.definition.title,
                            description=s.definition.description,
                            restart_required=s.definition.restart_required,
                            value=s.value) for s in data.values()
        ])
예제 #3
0
def _get_adv_settings_response(
) -> Dict[str, Union[Dict[str, str], List[Dict[str, Union[str, bool, None]]]]]:
    data = advs.get_all_adv_settings()

    if advs.is_restart_required():
        links = {'restart': '/server/restart'}
    else:
        links = {}

    return {
        'links':
        links,
        'settings': [{
            "id": s.definition.id,
            "old_id": s.definition.old_id,
            "title": s.definition.title,
            "description": s.definition.description,
            "restart_required": s.definition.restart_required,
            "value": s.value
        } for s in data.values()]
    }
예제 #4
0
async def test_restart_required(loop, restore_restart_required):
    assert advanced_settings.is_restart_required() is False
    _id = 'useV1HttpApi'
    await advanced_settings.set_adv_setting(_id, True)
    assert advanced_settings.is_restart_required() is True