Exemple #1
0
    def test_no_config(self):

        default_views = datapreview.get_default_view_plugins()

        assert sorted(
            [view_plugin.info()["name"] for view_plugin in default_views]
        ) == sorted(datapreview.DEFAULT_RESOURCE_VIEW_TYPES)
Exemple #2
0
    def test_both_plugins_in_config_only_non_datastore(self):

        default_views = datapreview.get_default_view_plugins()

        eq_(
            sorted(view_plugin.info()['name']
                   for view_plugin in default_views), ['image_view'])
Exemple #3
0
    def test_in_config(self):

        default_views = datapreview.get_default_view_plugins()

        eq_(
            sorted(view_plugin.info()['name']
                   for view_plugin in default_views), ['image_view'])
Exemple #4
0
    def test_in_config(self):

        default_views = datapreview.get_default_view_plugins()

        assert sorted(
            [view_plugin.info()["name"] for view_plugin in default_views]
        ) == ["image_view"]
    def test_in_config_datastore_view_only(self):

        default_views = datapreview.get_default_view_plugins(
            get_datastore_views=True)

        assert sorted([
            view_plugin.info()["name"] for view_plugin in default_views
        ]) == ["test_datastore_view"]
Exemple #6
0
    def test_in_config_datastore_view_only(self):

        default_views = datapreview.get_default_view_plugins(
            get_datastore_views=True)

        eq_(
            sorted(view_plugin.info()['name']
                   for view_plugin in default_views), ['test_datastore_view'])
Exemple #7
0
    def test_no_config(self):

        default_views = datapreview.get_default_view_plugins()

        eq_(
            sorted(
                [view_plugin.info()['name'] for view_plugin in default_views]),
            sorted(datapreview.DEFAULT_RESOURCE_VIEW_TYPES))
Exemple #8
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
    def create_views(self):
        #TODO: we need this method because of this bug - @deniszgonjanin
        #https://github.com/ckan/ckan/issues/2532
        view_plugins = [view_plugin.info()['name']
                        for view_plugin in get_default_view_plugins()]

        for p in get_action('package_list')({},{}):
            package = get_action('package_show')({}, {'id':p})

            add_views_to_dataset_resources({}, package, view_types=view_plugins)
    def create_views(self):
        # TODO: we need this method because of this bug - @deniszgonjanin
        # https://github.com/ckan/ckan/issues/2532
        view_plugins = [
            view_plugin.info()['name']
            for view_plugin in get_default_view_plugins()
        ]

        for p in get_action('package_list')({}, {}):
            package = get_action('package_show')({}, {'id': p})

            add_views_to_dataset_resources({},
                                           package,
                                           view_types=view_plugins)
Exemple #11
0
    def test_empty_config(self):

        default_views = datapreview.get_default_view_plugins()

        eq_(default_views, [])
Exemple #12
0
    def test_no_config(self):

        default_views = datapreview.get_default_view_plugins()

        eq_(sorted([view_plugin.info()['name'] for view_plugin in default_views]),
            sorted(datapreview.DEFAULT_RESOURCE_VIEW_TYPES))
Exemple #13
0
    def test_both_plugins_in_config_only_non_datastore(self):

        default_views = datapreview.get_default_view_plugins()

        eq_(sorted([view_plugin.info()['name'] for view_plugin in default_views]),
            ['image_view'])
Exemple #14
0
    def test_in_config_datastore_view_only_with_get_datastore_views(self):

        default_views = datapreview.get_default_view_plugins()

        eq_(default_views, [])
Exemple #15
0
    def test_empty_config(self):

        default_views = datapreview.get_default_view_plugins()

        eq_(default_views, [])
Exemple #16
0
    def test_in_config_datastore_view_only_with_get_datastore_views(self):

        default_views = datapreview.get_default_view_plugins()

        eq_(default_views, [])
Exemple #17
0
    def test_in_config(self):

        default_views = datapreview.get_default_view_plugins()

        eq_(sorted([view_plugin.info()['name'] for view_plugin in default_views]),
            ['image_view'])
Exemple #18
0
 def test_empty_config(self):
     default_views = datapreview.get_default_view_plugins()
     assert default_views == []
Exemple #19
0
    def test_both_plugins_in_config_only_non_datastore(self):
        default_views = datapreview.get_default_view_plugins()

        assert sorted(
            [view_plugin.info()["name"] for view_plugin in default_views]
        ) == ["image_view"]
Exemple #20
0
    def test_in_config_datastore_view_only(self):

        default_views = datapreview.get_default_view_plugins(get_datastore_views=True)

        eq_(sorted([view_plugin.info()['name'] for view_plugin in default_views]),
            ['test_datastore_view'])
Exemple #21
0
    def test_in_config_datastore_view_only_with_get_datastore_views(self):

        default_views = datapreview.get_default_view_plugins()

        assert default_views == []