Esempio n. 1
0
    def test_get_view_plugins(self):

        view_types = ['image_view', 'not_there', 'test_datastore_view']

        view_plugins = datapreview.get_view_plugins(view_types)

        eq_(len(view_plugins), 2)

        eq_(view_plugins[0].info()['name'], 'image_view')
        eq_(view_plugins[1].info()['name'], 'test_datastore_view')
Esempio n. 2
0
    def test_get_view_plugins(self):

        view_types = ["image_view", "not_there", "test_datastore_view"]

        view_plugins = datapreview.get_view_plugins(view_types)

        assert len(view_plugins) == 2

        assert view_plugins[0].info()["name"] == "image_view"
        assert view_plugins[1].info()["name"] == "test_datastore_view"
Esempio n. 3
0
    def test_get_view_plugins(self):

        view_types = ['image_view', 'not_there', 'test_datastore_view']

        view_plugins = datapreview.get_view_plugins(view_types)

        eq_(len(view_plugins), 2)

        eq_(view_plugins[0].info()['name'], 'image_view')
        eq_(view_plugins[1].info()['name'], 'test_datastore_view')
Esempio n. 4
0
def _get_view_plugins(view_plugin_types: list[str],
                      get_datastore_views: bool = False):
    """Returns the view plugins that were succesfully loaded

    Views are provided as a list of ``view_plugin_types``. If no types
    are provided, the default views defined in the
    ``ckan.views.default_views`` will be created. Only in this case
    (when the default view plugins are used) the `get_datastore_views`
    parameter can be used to get also view plugins that require data
    to be in the DataStore.

    If any of the provided plugins could not be loaded (eg it was not
    added to `ckan.plugins`) the command will stop.

    Returns a list of loaded plugin names.

    """

    view_plugins = []

    if not view_plugin_types:
        click.secho(u"No view types provided, using default types")
        view_plugins = get_default_view_plugins()
        if get_datastore_views:
            view_plugins.extend(
                get_default_view_plugins(get_datastore_views=True)
            )
    else:
        view_plugins = get_view_plugins(view_plugin_types)

    loaded_view_plugins = [
        view_plugin.info()[u"name"] for view_plugin in view_plugins
    ]

    plugins_not_found = list(set(view_plugin_types) - set(loaded_view_plugins))

    if plugins_not_found:
        error_shout(
            u"View plugin(s) not found : {0}. ".format(plugins_not_found)
            + u"Have they been added to the `ckan.plugins` configuration"
            + u" option?"
        )
        return None
    return loaded_view_plugins