From 1813413b33170f87cc9fb721c7b5a8cdecfab722 Mon Sep 17 00:00:00 2001 From: pdelboca Date: Mon, 30 May 2022 12:26:50 +0200 Subject: [PATCH] Fix fixture for older versions --- ckanext/googleanalytics/tests/conftest.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ckanext/googleanalytics/tests/conftest.py b/ckanext/googleanalytics/tests/conftest.py index 7fe6cf5..b5f5422 100644 --- a/ckanext/googleanalytics/tests/conftest.py +++ b/ckanext/googleanalytics/tests/conftest.py @@ -3,16 +3,25 @@ import factory from factory.alchemy import SQLAlchemyModelFactory from pytest_factoryboy import register +from ckan.plugins import toolkit import ckan.model as model from ckanext.googleanalytics.model import PackageStats, ResourceStats -@pytest.fixture() -def clean_db(reset_db, migrate_db_for): - reset_db() - migrate_db_for("googleanalytics") +if toolkit.requires_ckan_version("2.9"): + @pytest.fixture() + def clean_db(reset_db, migrate_db_for): + reset_db() + migrate_db_for("googleanalytics") +else: + from dbutil import init_tables + @pytest.fixture() + def clean_db(reset_db): + reset_db() + init_tables() + @register