コード例 #1
0
def test_plugin_update_saves_boolean_as_boolean(
    staff_api_client_can_manage_plugins, settings
):
    settings.PLUGINS = ["tests.plugins.sample_plugins.PluginSample"]
    manager = get_plugins_manager()
    plugin = manager.get_plugin(PluginSample.PLUGIN_NAME)
    use_sandbox = get_config_value("Use sandbox", plugin.configuration)
    variables = {
        "id": plugin.PLUGIN_NAME,
        "active": plugin.active,
        "configuration": [{"name": "Use sandbox", "value": True}],
    }
    response = staff_api_client_can_manage_plugins.post_graphql(
        PLUGIN_UPDATE_MUTATION, variables
    )
    content = get_graphql_content(response)
    assert len(content["data"]["pluginUpdate"]["errors"]) == 0
    use_sandbox_new_value = get_config_value("Use sandbox", plugin.configuration)
    assert type(use_sandbox) == type(use_sandbox_new_value)
コード例 #2
0
def test_update_config_items_keeps_bool_value(plugin_configuration, settings):
    settings.PLUGINS = ["tests.plugins.sample_plugins.PluginSample"]
    data_to_update = [
        {
            "name": "Username",
            "value": "*****@*****.**"
        },
        {
            "name": "Use sandbox",
            "value": False
        },
    ]
    manager = get_plugins_manager()
    plugin_sample = manager.get_plugin(PluginSample.PLUGIN_ID)
    plugin_sample._update_config_items(data_to_update,
                                       plugin_sample.configuration)

    assert get_config_value("Use sandbox",
                            plugin_sample.configuration) is False
コード例 #3
0
def test_update_config_items_convert_to_bool_value():
    data_to_update = [
        {
            "name": "Username",
            "value": "*****@*****.**"
        },
        {
            "name": "Use sandbox",
            "value": "false"
        },
    ]
    plugin_sample = PluginSample(
        configuration=PluginSample.DEFAULT_CONFIGURATION,
        active=PluginSample.DEFAULT_ACTIVE,
    )
    plugin_sample._update_config_items(data_to_update,
                                       plugin_sample.configuration)

    assert get_config_value("Use sandbox",
                            plugin_sample.configuration) is False