diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c320f84..68c0226 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,8 +55,8 @@ jobs: sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini ckan -c test.ini db init - ckan -c test.ini db upgrade -p tracking + ckan -c test.ini db upgrade -p api_tracking - name: Run tests - run: pytest --ckan-ini=test.ini -v --disable-warnings ckanext/tracking + run: pytest --ckan-ini=test.ini -v --disable-warnings ckanext/api_tracking diff --git a/MANIFEST.in b/MANIFEST.in index 7589c43..10b377d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ include README.md include LICENSE include requirements.txt -recursive-include ckanext/tracking *.html *.json *.js *.less *.css *.mo *.yml -recursive-include ckanext/tracking/migration *.ini *.py *.mako +recursive-include ckanext/api_tracking *.html *.json *.js *.less *.css *.mo *.yml +recursive-include ckanext/api_tracking/migration *.ini *.py *.mako diff --git a/ckanext/api_tracking/__init__.py b/ckanext/api_tracking/__init__.py new file mode 100644 index 0000000..b4efc82 --- /dev/null +++ b/ckanext/api_tracking/__init__.py @@ -0,0 +1 @@ +__VERSION__ = '0.4.0' diff --git a/ckanext/tracking/actions/__init__.py b/ckanext/api_tracking/actions/__init__.py similarity index 100% rename from ckanext/tracking/actions/__init__.py rename to ckanext/api_tracking/actions/__init__.py diff --git a/ckanext/tracking/actions/queries.py b/ckanext/api_tracking/actions/queries.py similarity index 96% rename from ckanext/tracking/actions/queries.py rename to ckanext/api_tracking/actions/queries.py index 9e17fc0..ebb225f 100644 --- a/ckanext/tracking/actions/queries.py +++ b/ckanext/api_tracking/actions/queries.py @@ -1,5 +1,5 @@ from ckan.plugins import toolkit -from ckanext.tracking.queries.api import ( +from ckanext.api_tracking.queries.api import ( get_all_token_usage, get_most_accessed_dataset_with_token, get_most_accessed_token, diff --git a/ckanext/tracking/assets/.gitignore b/ckanext/api_tracking/assets/.gitignore similarity index 100% rename from ckanext/tracking/assets/.gitignore rename to ckanext/api_tracking/assets/.gitignore diff --git a/ckanext/tracking/assets/script.js b/ckanext/api_tracking/assets/script.js similarity index 100% rename from ckanext/tracking/assets/script.js rename to ckanext/api_tracking/assets/script.js diff --git a/ckanext/tracking/assets/style.css b/ckanext/api_tracking/assets/style.css similarity index 100% rename from ckanext/tracking/assets/style.css rename to ckanext/api_tracking/assets/style.css diff --git a/ckanext/tracking/assets/webassets.yml b/ckanext/api_tracking/assets/webassets.yml similarity index 100% rename from ckanext/tracking/assets/webassets.yml rename to ckanext/api_tracking/assets/webassets.yml diff --git a/ckanext/tracking/auth/__init__.py b/ckanext/api_tracking/auth/__init__.py similarity index 100% rename from ckanext/tracking/auth/__init__.py rename to ckanext/api_tracking/auth/__init__.py diff --git a/ckanext/tracking/auth/csv.py b/ckanext/api_tracking/auth/csv.py similarity index 100% rename from ckanext/tracking/auth/csv.py rename to ckanext/api_tracking/auth/csv.py diff --git a/ckanext/tracking/auth/queries.py b/ckanext/api_tracking/auth/queries.py similarity index 100% rename from ckanext/tracking/auth/queries.py rename to ckanext/api_tracking/auth/queries.py diff --git a/ckanext/api_tracking/blueprints/__init__.py b/ckanext/api_tracking/blueprints/__init__.py new file mode 100644 index 0000000..a596163 --- /dev/null +++ b/ckanext/api_tracking/blueprints/__init__.py @@ -0,0 +1,4 @@ +# flake8: noqa: F401 + +from ckanext.api_tracking.blueprints.csv import tracking_csv_blueprint +from ckanext.api_tracking.blueprints.dashboard import tracking_dashboard_blueprint \ No newline at end of file diff --git a/ckanext/tracking/blueprints/csv.py b/ckanext/api_tracking/blueprints/csv.py similarity index 97% rename from ckanext/tracking/blueprints/csv.py rename to ckanext/api_tracking/blueprints/csv.py index 2fc5b61..169ecba 100644 --- a/ckanext/tracking/blueprints/csv.py +++ b/ckanext/api_tracking/blueprints/csv.py @@ -6,7 +6,7 @@ from ckan.common import current_user from ckan.plugins import toolkit -from ckanext.tracking.queries.data import ( +from ckanext.api_tracking.queries.data import ( all_token_usage_data, most_accessed_token_data, most_accessed_dataset_with_token_data, diff --git a/ckanext/tracking/blueprints/dashboard.py b/ckanext/api_tracking/blueprints/dashboard.py similarity index 93% rename from ckanext/tracking/blueprints/dashboard.py rename to ckanext/api_tracking/blueprints/dashboard.py index 8e1a497..feee61f 100644 --- a/ckanext/tracking/blueprints/dashboard.py +++ b/ckanext/api_tracking/blueprints/dashboard.py @@ -2,9 +2,9 @@ from flask import Blueprint from ckan.plugins.toolkit import render, h from ckanext.stats import stats as stats_lib -from ckanext.tracking.dashboard.stats import get_dataset_views, get_unique_dataset_views, get_resource_downloads -from ckanext.tracking.dashboard.stats_api import get_api_token_usage_aggregated, get_latest_api_token_usage -from ckanext.tracking.decorators import require_sysadmin_user +from ckanext.api_tracking.dashboard.stats import get_dataset_views, get_unique_dataset_views, get_resource_downloads +from ckanext.api_tracking.dashboard.stats_api import get_api_token_usage_aggregated, get_latest_api_token_usage +from ckanext.api_tracking.decorators import require_sysadmin_user log = logging.getLogger(__name__) diff --git a/ckanext/tracking/dashboard/__init__.py b/ckanext/api_tracking/dashboard/__init__.py similarity index 100% rename from ckanext/tracking/dashboard/__init__.py rename to ckanext/api_tracking/dashboard/__init__.py diff --git a/ckanext/tracking/dashboard/sql/api-token-usage-aggregated-by-dataset.sql b/ckanext/api_tracking/dashboard/sql/api-token-usage-aggregated-by-dataset.sql similarity index 100% rename from ckanext/tracking/dashboard/sql/api-token-usage-aggregated-by-dataset.sql rename to ckanext/api_tracking/dashboard/sql/api-token-usage-aggregated-by-dataset.sql diff --git a/ckanext/tracking/dashboard/sql/api-token-usage-aggregated-by-token.sql b/ckanext/api_tracking/dashboard/sql/api-token-usage-aggregated-by-token.sql similarity index 100% rename from ckanext/tracking/dashboard/sql/api-token-usage-aggregated-by-token.sql rename to ckanext/api_tracking/dashboard/sql/api-token-usage-aggregated-by-token.sql diff --git a/ckanext/tracking/dashboard/sql/downloaded-resources.sql b/ckanext/api_tracking/dashboard/sql/downloaded-resources.sql similarity index 100% rename from ckanext/tracking/dashboard/sql/downloaded-resources.sql rename to ckanext/api_tracking/dashboard/sql/downloaded-resources.sql diff --git a/ckanext/tracking/dashboard/sql/latest-api-token-usage.sql b/ckanext/api_tracking/dashboard/sql/latest-api-token-usage.sql similarity index 100% rename from ckanext/tracking/dashboard/sql/latest-api-token-usage.sql rename to ckanext/api_tracking/dashboard/sql/latest-api-token-usage.sql diff --git a/ckanext/tracking/dashboard/sql/viewed-datasets-unique.sql b/ckanext/api_tracking/dashboard/sql/viewed-datasets-unique.sql similarity index 88% rename from ckanext/tracking/dashboard/sql/viewed-datasets-unique.sql rename to ckanext/api_tracking/dashboard/sql/viewed-datasets-unique.sql index 69b30f1..64f6dee 100644 --- a/ckanext/tracking/dashboard/sql/viewed-datasets-unique.sql +++ b/ckanext/api_tracking/dashboard/sql/viewed-datasets-unique.sql @@ -4,7 +4,7 @@ If a user views a dataset multiple times in a period, it will only be counted on Based on the tracking_raw table because the tracking_summary table does not allow to count unique views in a period. -This query is used in ckanext/tracking/dashboard/stats.py module to collect views statistics. +This query is used in ckanext/api_tracking/dashboard/stats.py module to collect views statistics. */ SELECT diff --git a/ckanext/tracking/dashboard/sql/viewed-datasets.sql b/ckanext/api_tracking/dashboard/sql/viewed-datasets.sql similarity index 100% rename from ckanext/tracking/dashboard/sql/viewed-datasets.sql rename to ckanext/api_tracking/dashboard/sql/viewed-datasets.sql diff --git a/ckanext/tracking/dashboard/stats.py b/ckanext/api_tracking/dashboard/stats.py similarity index 97% rename from ckanext/tracking/dashboard/stats.py rename to ckanext/api_tracking/dashboard/stats.py index ebb3b92..4d8cd80 100644 --- a/ckanext/tracking/dashboard/stats.py +++ b/ckanext/api_tracking/dashboard/stats.py @@ -4,7 +4,7 @@ import logging from datetime import datetime, timedelta from ckan import model -from ckanext.tracking.dashboard import query_results +from ckanext.api_tracking.dashboard import query_results log = logging.getLogger(__name__) diff --git a/ckanext/tracking/dashboard/stats_api.py b/ckanext/api_tracking/dashboard/stats_api.py similarity index 97% rename from ckanext/tracking/dashboard/stats_api.py rename to ckanext/api_tracking/dashboard/stats_api.py index 17bdaef..6b6b6e0 100644 --- a/ckanext/tracking/dashboard/stats_api.py +++ b/ckanext/api_tracking/dashboard/stats_api.py @@ -3,7 +3,7 @@ """ import logging from ckan.plugins import toolkit -from ckanext.tracking.queries.data import ( +from ckanext.api_tracking.queries.data import ( all_token_usage_data, most_accessed_token_data, most_accessed_dataset_with_token_data, diff --git a/ckanext/tracking/decorators.py b/ckanext/api_tracking/decorators.py similarity index 100% rename from ckanext/tracking/decorators.py rename to ckanext/api_tracking/decorators.py diff --git a/ckanext/tracking/i18n/.gitignore b/ckanext/api_tracking/i18n/.gitignore similarity index 100% rename from ckanext/tracking/i18n/.gitignore rename to ckanext/api_tracking/i18n/.gitignore diff --git a/ckanext/tracking/interfaces.py b/ckanext/api_tracking/interfaces.py similarity index 99% rename from ckanext/tracking/interfaces.py rename to ckanext/api_tracking/interfaces.py index 56d71fa..c9a1e31 100644 --- a/ckanext/tracking/interfaces.py +++ b/ckanext/api_tracking/interfaces.py @@ -1,7 +1,7 @@ import logging from ckan import plugins from ckan.plugins.interfaces import Interface -from ckanext.tracking.models import TrackingUsage, CKANURL +from ckanext.api_tracking.models import TrackingUsage, CKANURL log = logging.getLogger(__name__) diff --git a/ckanext/tracking/middleware.py b/ckanext/api_tracking/middleware.py similarity index 98% rename from ckanext/tracking/middleware.py rename to ckanext/api_tracking/middleware.py index 9719631..424fcc5 100644 --- a/ckanext/tracking/middleware.py +++ b/ckanext/api_tracking/middleware.py @@ -7,7 +7,7 @@ from ckan.model import ApiToken from ckan.types import CKANApp -from ckanext.tracking.interfaces import IUsage +from ckanext.api_tracking.interfaces import IUsage log = logging.getLogger(__name__) diff --git a/ckanext/tracking/migration/tracking/alembic.ini b/ckanext/api_tracking/migration/api_tracking/alembic.ini similarity index 100% rename from ckanext/tracking/migration/tracking/alembic.ini rename to ckanext/api_tracking/migration/api_tracking/alembic.ini diff --git a/ckanext/tracking/migration/tracking/env.py b/ckanext/api_tracking/migration/api_tracking/env.py similarity index 100% rename from ckanext/tracking/migration/tracking/env.py rename to ckanext/api_tracking/migration/api_tracking/env.py diff --git a/ckanext/tracking/migration/tracking/versions/001_95aed1f25344_init_extension_models.py b/ckanext/api_tracking/migration/api_tracking/versions/001_95aed1f25344_init_extension_models.py similarity index 100% rename from ckanext/tracking/migration/tracking/versions/001_95aed1f25344_init_extension_models.py rename to ckanext/api_tracking/migration/api_tracking/versions/001_95aed1f25344_init_extension_models.py diff --git a/ckanext/api_tracking/models/__init__.py b/ckanext/api_tracking/models/__init__.py new file mode 100644 index 0000000..44bd870 --- /dev/null +++ b/ckanext/api_tracking/models/__init__.py @@ -0,0 +1,4 @@ +# flake8: noqa: F401 + +from ckanext.api_tracking.models.tracking import TrackingUsage +from ckanext.api_tracking.models.url import CKANURL diff --git a/ckanext/tracking/models/tracking.py b/ckanext/api_tracking/models/tracking.py similarity index 100% rename from ckanext/tracking/models/tracking.py rename to ckanext/api_tracking/models/tracking.py diff --git a/ckanext/tracking/models/url.py b/ckanext/api_tracking/models/url.py similarity index 100% rename from ckanext/tracking/models/url.py rename to ckanext/api_tracking/models/url.py diff --git a/ckanext/tracking/plugin.py b/ckanext/api_tracking/plugin.py similarity index 86% rename from ckanext/tracking/plugin.py rename to ckanext/api_tracking/plugin.py index 11228a7..a703ae4 100644 --- a/ckanext/tracking/plugin.py +++ b/ckanext/api_tracking/plugin.py @@ -2,12 +2,12 @@ from ckan import plugins from ckan.plugins import toolkit -from ckanext.tracking import blueprints -from ckanext.tracking.interfaces import IUsage -from ckanext.tracking.middleware import TrackingUsageMiddleware -from ckanext.tracking.auth import csv as auth_csv -from ckanext.tracking.auth import queries as auth_queries -from ckanext.tracking.actions import queries as action_queries +from ckanext.api_tracking import blueprints +from ckanext.api_tracking.interfaces import IUsage +from ckanext.api_tracking.middleware import TrackingUsageMiddleware +from ckanext.api_tracking.auth import csv as auth_csv +from ckanext.api_tracking.auth import queries as auth_queries +from ckanext.api_tracking.actions import queries as action_queries log = logging.getLogger(__name__) diff --git a/ckanext/tracking/public/.gitignore b/ckanext/api_tracking/public/.gitignore similarity index 100% rename from ckanext/tracking/public/.gitignore rename to ckanext/api_tracking/public/.gitignore diff --git a/ckanext/tracking/queries/__init__.py b/ckanext/api_tracking/queries/__init__.py similarity index 100% rename from ckanext/tracking/queries/__init__.py rename to ckanext/api_tracking/queries/__init__.py diff --git a/ckanext/tracking/queries/api.py b/ckanext/api_tracking/queries/api.py similarity index 96% rename from ckanext/tracking/queries/api.py rename to ckanext/api_tracking/queries/api.py index 2250596..d3d9b55 100644 --- a/ckanext/tracking/queries/api.py +++ b/ckanext/api_tracking/queries/api.py @@ -1,6 +1,6 @@ from ckan import model from sqlalchemy import func, desc -from ckanext.tracking.models import TrackingUsage +from ckanext.api_tracking.models import TrackingUsage def get_most_accessed_dataset_with_token(limit=10): diff --git a/ckanext/api_tracking/queries/data/__init__.py b/ckanext/api_tracking/queries/data/__init__.py new file mode 100644 index 0000000..1f52d4c --- /dev/null +++ b/ckanext/api_tracking/queries/data/__init__.py @@ -0,0 +1,5 @@ +# flake8: noqa: F401 + +from ckanext.api_tracking.queries.data.all import all_token_usage_data +from ckanext.api_tracking.queries.data.dataset import most_accessed_dataset_with_token_data +from ckanext.api_tracking.queries.data.token import most_accessed_token_data diff --git a/ckanext/tracking/queries/data/all.py b/ckanext/api_tracking/queries/data/all.py similarity index 97% rename from ckanext/tracking/queries/data/all.py rename to ckanext/api_tracking/queries/data/all.py index 3ef08d2..a4dc3b4 100644 --- a/ckanext/tracking/queries/data/all.py +++ b/ckanext/api_tracking/queries/data/all.py @@ -6,7 +6,7 @@ from ckan import model from ckan.plugins import toolkit -from ckanext.tracking.queries.api import get_all_token_usage +from ckanext.api_tracking.queries.api import get_all_token_usage log = logging.getLogger(__name__) diff --git a/ckanext/tracking/queries/data/dataset.py b/ckanext/api_tracking/queries/data/dataset.py similarity index 91% rename from ckanext/tracking/queries/data/dataset.py rename to ckanext/api_tracking/queries/data/dataset.py index a644804..20d49e7 100644 --- a/ckanext/tracking/queries/data/dataset.py +++ b/ckanext/api_tracking/queries/data/dataset.py @@ -6,7 +6,7 @@ from ckan import model from ckan.plugins import toolkit -from ckanext.tracking.queries.api import get_most_accessed_dataset_with_token +from ckanext.api_tracking.queries.api import get_most_accessed_dataset_with_token log = logging.getLogger(__name__) diff --git a/ckanext/tracking/queries/data/token.py b/ckanext/api_tracking/queries/data/token.py similarity index 93% rename from ckanext/tracking/queries/data/token.py rename to ckanext/api_tracking/queries/data/token.py index a1bb2d8..4617b61 100644 --- a/ckanext/tracking/queries/data/token.py +++ b/ckanext/api_tracking/queries/data/token.py @@ -6,7 +6,7 @@ from ckan import model from ckan.plugins import toolkit -from ckanext.tracking.queries.api import get_most_accessed_token +from ckanext.api_tracking.queries.api import get_most_accessed_token log = logging.getLogger(__name__) diff --git a/ckanext/tracking/templates/.gitignore b/ckanext/api_tracking/templates/.gitignore similarity index 100% rename from ckanext/tracking/templates/.gitignore rename to ckanext/api_tracking/templates/.gitignore diff --git a/ckanext/tracking/templates/dashboard/api-token-usage-aggregated.html b/ckanext/api_tracking/templates/dashboard/api-token-usage-aggregated.html similarity index 100% rename from ckanext/tracking/templates/dashboard/api-token-usage-aggregated.html rename to ckanext/api_tracking/templates/dashboard/api-token-usage-aggregated.html diff --git a/ckanext/tracking/templates/dashboard/base.html b/ckanext/api_tracking/templates/dashboard/base.html similarity index 100% rename from ckanext/tracking/templates/dashboard/base.html rename to ckanext/api_tracking/templates/dashboard/base.html diff --git a/ckanext/tracking/templates/dashboard/dataset-unique-views.html b/ckanext/api_tracking/templates/dashboard/dataset-unique-views.html similarity index 100% rename from ckanext/tracking/templates/dashboard/dataset-unique-views.html rename to ckanext/api_tracking/templates/dashboard/dataset-unique-views.html diff --git a/ckanext/tracking/templates/dashboard/dataset-views.html b/ckanext/api_tracking/templates/dashboard/dataset-views.html similarity index 100% rename from ckanext/tracking/templates/dashboard/dataset-views.html rename to ckanext/api_tracking/templates/dashboard/dataset-views.html diff --git a/ckanext/tracking/templates/dashboard/edited-datasets.html b/ckanext/api_tracking/templates/dashboard/edited-datasets.html similarity index 100% rename from ckanext/tracking/templates/dashboard/edited-datasets.html rename to ckanext/api_tracking/templates/dashboard/edited-datasets.html diff --git a/ckanext/tracking/templates/dashboard/largest-groups.html b/ckanext/api_tracking/templates/dashboard/largest-groups.html similarity index 100% rename from ckanext/tracking/templates/dashboard/largest-groups.html rename to ckanext/api_tracking/templates/dashboard/largest-groups.html diff --git a/ckanext/tracking/templates/dashboard/latest-api-token-usage.html b/ckanext/api_tracking/templates/dashboard/latest-api-token-usage.html similarity index 100% rename from ckanext/tracking/templates/dashboard/latest-api-token-usage.html rename to ckanext/api_tracking/templates/dashboard/latest-api-token-usage.html diff --git a/ckanext/tracking/templates/dashboard/most-create.html b/ckanext/api_tracking/templates/dashboard/most-create.html similarity index 100% rename from ckanext/tracking/templates/dashboard/most-create.html rename to ckanext/api_tracking/templates/dashboard/most-create.html diff --git a/ckanext/tracking/templates/dashboard/resource-downloads.html b/ckanext/api_tracking/templates/dashboard/resource-downloads.html similarity index 100% rename from ckanext/tracking/templates/dashboard/resource-downloads.html rename to ckanext/api_tracking/templates/dashboard/resource-downloads.html diff --git a/ckanext/tracking/templates/dashboard/total-datasets.html b/ckanext/api_tracking/templates/dashboard/total-datasets.html similarity index 100% rename from ckanext/tracking/templates/dashboard/total-datasets.html rename to ckanext/api_tracking/templates/dashboard/total-datasets.html diff --git a/ckanext/tracking/tests/__init__.py b/ckanext/api_tracking/tests/__init__.py similarity index 100% rename from ckanext/tracking/tests/__init__.py rename to ckanext/api_tracking/tests/__init__.py diff --git a/ckanext/tracking/tests/factories.py b/ckanext/api_tracking/tests/factories.py similarity index 97% rename from ckanext/tracking/tests/factories.py rename to ckanext/api_tracking/tests/factories.py index 2516ac8..c430ea7 100644 --- a/ckanext/tracking/tests/factories.py +++ b/ckanext/api_tracking/tests/factories.py @@ -2,7 +2,7 @@ from ckan import model from ckan.plugins import toolkit from ckantoolkit.tests import factories -from ckanext.tracking.models import TrackingUsage +from ckanext.api_tracking.models import TrackingUsage class TrackingUsageF(factory.Factory): diff --git a/ckanext/api_tracking/tests/fixtures.py b/ckanext/api_tracking/tests/fixtures.py new file mode 100644 index 0000000..d902d1a --- /dev/null +++ b/ckanext/api_tracking/tests/fixtures.py @@ -0,0 +1,7 @@ +import pytest + + +@pytest.fixture +def api_tracking_migrate(migrate_db_for): + """ Apply the tracking migrations """ + migrate_db_for('api_tracking') diff --git a/ckanext/tracking/tests/test_csv.py b/ckanext/api_tracking/tests/test_csv.py similarity index 96% rename from ckanext/tracking/tests/test_csv.py rename to ckanext/api_tracking/tests/test_csv.py index 9ea43e6..66d0123 100644 --- a/ckanext/tracking/tests/test_csv.py +++ b/ckanext/api_tracking/tests/test_csv.py @@ -4,7 +4,7 @@ from ckan.lib.helpers import url_for from ckan.tests import factories -from ckanext.tracking.tests import factories as tf +from ckanext.api_tracking.tests import factories as tf @pytest.fixture @@ -24,7 +24,7 @@ def base_data(): return obj -@pytest.mark.usefixtures('clean_db', 'tracking_migrate') +@pytest.mark.usefixtures('clean_db', 'api_tracking_migrate') class TestTrackingCSVView: """ Test basic tracking from requests """ def test_dataset_with_token_csv_no_user(self, app): diff --git a/ckanext/tracking/tests/test_dashboard_tab.py b/ckanext/api_tracking/tests/test_dashboard_tab.py similarity index 93% rename from ckanext/tracking/tests/test_dashboard_tab.py rename to ckanext/api_tracking/tests/test_dashboard_tab.py index cf68329..12e7f61 100644 --- a/ckanext/tracking/tests/test_dashboard_tab.py +++ b/ckanext/api_tracking/tests/test_dashboard_tab.py @@ -18,7 +18,7 @@ def setup_data(): return obj -@pytest.mark.usefixtures('clean_db', 'clean_index', 'tracking_migrate') +@pytest.mark.usefixtures('clean_db', 'clean_index', 'api_tracking_migrate') class TestDashboardTab: """ Test who can see the dashboard tab """ def test_member_admin_cant_see(self, app, setup_data): diff --git a/ckanext/tracking/tests/test_dashboard_tabs.py b/ckanext/api_tracking/tests/test_dashboard_tabs.py similarity index 95% rename from ckanext/tracking/tests/test_dashboard_tabs.py rename to ckanext/api_tracking/tests/test_dashboard_tabs.py index 0794711..d1159f0 100644 --- a/ckanext/tracking/tests/test_dashboard_tabs.py +++ b/ckanext/api_tracking/tests/test_dashboard_tabs.py @@ -30,7 +30,7 @@ def setup_data(): return obj -@pytest.mark.usefixtures('clean_db', 'clean_index', 'tracking_migrate') +@pytest.mark.usefixtures('clean_db', 'clean_index', 'api_tracking_migrate') class TestDashboardTabs: """ Test dashboard tabks """ def _test_dashboard_tab(self, app, user, fn, status): diff --git a/ckanext/tracking/tests/test_middleware.py b/ckanext/api_tracking/tests/test_middleware.py similarity index 100% rename from ckanext/tracking/tests/test_middleware.py rename to ckanext/api_tracking/tests/test_middleware.py diff --git a/ckanext/tracking/tests/test_plugin.py b/ckanext/api_tracking/tests/test_plugin.py similarity index 92% rename from ckanext/tracking/tests/test_plugin.py rename to ckanext/api_tracking/tests/test_plugin.py index 2724934..1837049 100644 --- a/ckanext/tracking/tests/test_plugin.py +++ b/ckanext/api_tracking/tests/test_plugin.py @@ -51,7 +51,7 @@ def test_some_action(): from ckan import plugins -@pytest.mark.ckan_config("ckan.plugins", "tracking") +@pytest.mark.ckan_config("ckan.plugins", "api_tracking") @pytest.mark.usefixtures("with_plugins") def test_plugin(): - assert plugins.plugin_loaded("tracking") + assert plugins.plugin_loaded("api_tracking") diff --git a/ckanext/tracking/tests/test_tracking_basic.py b/ckanext/api_tracking/tests/test_tracking_basic.py similarity index 99% rename from ckanext/tracking/tests/test_tracking_basic.py rename to ckanext/api_tracking/tests/test_tracking_basic.py index 44d9189..b6da2c1 100644 --- a/ckanext/tracking/tests/test_tracking_basic.py +++ b/ckanext/api_tracking/tests/test_tracking_basic.py @@ -3,7 +3,7 @@ from ckan.lib.helpers import url_for from ckan.tests import factories -from ckanext.tracking.models.tracking import TrackingUsage +from ckanext.api_tracking.models.tracking import TrackingUsage class TestTrackingUsageBasic: diff --git a/ckanext/tracking/__init__.py b/ckanext/tracking/__init__.py deleted file mode 100644 index 8cd4791..0000000 --- a/ckanext/tracking/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__VERSION__ = '0.3.2' diff --git a/ckanext/tracking/blueprints/__init__.py b/ckanext/tracking/blueprints/__init__.py deleted file mode 100644 index 9c1f043..0000000 --- a/ckanext/tracking/blueprints/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# flake8: noqa: F401 - -from ckanext.tracking.blueprints.csv import tracking_csv_blueprint -from ckanext.tracking.blueprints.dashboard import tracking_dashboard_blueprint \ No newline at end of file diff --git a/ckanext/tracking/models/__init__.py b/ckanext/tracking/models/__init__.py deleted file mode 100644 index 316ce0a..0000000 --- a/ckanext/tracking/models/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# flake8: noqa: F401 - -from ckanext.tracking.models.tracking import TrackingUsage -from ckanext.tracking.models.url import CKANURL diff --git a/ckanext/tracking/queries/data/__init__.py b/ckanext/tracking/queries/data/__init__.py deleted file mode 100644 index d32cc62..0000000 --- a/ckanext/tracking/queries/data/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# flake8: noqa: F401 - -from ckanext.tracking.queries.data.all import all_token_usage_data -from ckanext.tracking.queries.data.dataset import most_accessed_dataset_with_token_data -from ckanext.tracking.queries.data.token import most_accessed_token_data diff --git a/ckanext/tracking/tests/fixtures.py b/ckanext/tracking/tests/fixtures.py deleted file mode 100644 index 7212e11..0000000 --- a/ckanext/tracking/tests/fixtures.py +++ /dev/null @@ -1,7 +0,0 @@ -import pytest - - -@pytest.fixture -def tracking_migrate(migrate_db_for): - """ Apply the tracking migrations """ - migrate_db_for('tracking') diff --git a/conftest.py b/conftest.py index 628b203..c405e9c 100644 --- a/conftest.py +++ b/conftest.py @@ -1,3 +1,3 @@ pytest_plugins = [ - u'ckanext.tracking.tests.fixtures', + u'ckanext.api_tracking.tests.fixtures', ] diff --git a/pyproject.toml b/pyproject.toml index c65edc4..a7afd9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=61", "wheel"] build-backend = "setuptools.build_meta" [project] -name = "ckanext-tracking" +name = "ckanext-api-tracking" # see tool.setuptools.dynamic in this file dynamic = ["version"] description = "CKAN extension to track users activity" @@ -29,8 +29,8 @@ classifiers = [ ] [project.urls] -"Homepage" = "https://github.com/NorwegianRefugeeCouncil/ckanext-tracking" -"Issues" = "https://github.com/NorwegianRefugeeCouncil/ckanext-tracking/issues" +"Homepage" = "https://github.com/NorwegianRefugeeCouncil/ckanext-api-tracking" +"Issues" = "https://github.com/NorwegianRefugeeCouncil/ckanext-api-tracking/issues" # [project.dependencies] # Dependencies should be listed in requirements.txt as per CKAN extension best practices @@ -54,7 +54,7 @@ namespaces = true include = ["*"] [tool.setuptools.dynamic] -version = {attr = "ckanext.tracking.__VERSION__"} +version = {attr = "ckanext.api_tracking.__VERSION__"} [tool.setuptools.data-files] # Data files can be listed here @@ -67,7 +67,7 @@ version = {attr = "ckanext.tracking.__VERSION__"} # your_command = "your_module:main" [project.entry-points."ckan.plugins"] -tracking = "ckanext.tracking.plugin:TrackingPlugin" +api_tracking = "ckanext.api_tracking.plugin:TrackingPlugin" [project.entry-points."babel.extractors"] ckan = "ckan.lib.extract:extract_ckan" diff --git a/test.ini b/test.ini index f0d1eda..fa84f4f 100644 --- a/test.ini +++ b/test.ini @@ -4,16 +4,11 @@ smtp_server = localhost error_email_from = ckan@localhost [app:main] -ckan.datastore.read_url = postgresql://datastore_read:pass@postgresql_nrc/datastore_test -ckan.datastore.write_url = postgresql://datastore_write:pass@postgresql_nrc/datastore_test -solr_url = http://solr_nrc:8983/solr/ckan -ckan.redis.url = redis://redis_nrc:6379/0 -sqlalchemy.url = postgresql://ckan_default:pass@postgresql_nrc/ckan_test use = config:../../ckan/test-core.ini # Insert any custom config settings to be used when running your extension's # tests here. These will override the one defined in CKAN core's test-core.ini -ckan.plugins = tracking +ckan.plugins = api_tracking # Logging configuration