Skip to content

Commit

Permalink
Merge pull request #263 from GovDataOfficial/fix-tests
Browse files Browse the repository at this point in the history
Adapt tests to latest changes in ckanext-harvest
  • Loading branch information
amercader authored Feb 27, 2024
2 parents 1109205 + baa07d7 commit f147f21
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Setup extension
run: |
ckan -c test.ini db init
ckan -c test.ini harvester initdb
ckan -c test.ini db pending-migrations --apply
- name: Run tests
run: pytest --ckan-ini=test.ini --cov=ckanext.dcat --cov-report=xml --cov-append --disable-warnings ckanext/dcat/tests
- name: Upload coverage report to codecov
Expand Down
9 changes: 9 additions & 0 deletions ckanext/dcat/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest

import ckan.plugins as p

@pytest.fixture
def clean_db(reset_db, migrate_db_for):
reset_db()
if p.get_plugin('harvest'):
migrate_db_for('harvest')
12 changes: 1 addition & 11 deletions ckanext/dcat/tests/test_harvester.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@




# TODO move to ckanext-harvest
@pytest.fixture
def harvest_setup():
harvest_model.setup()


@pytest.fixture
def clean_queues():
queue.purge_queues()
Expand Down Expand Up @@ -624,7 +617,7 @@ def _run_full_job(self, harvest_source_id, num_jobs=1, num_objects=1):
self._fetch_queue(num_objects)


@pytest.mark.usefixtures('with_plugins', 'clean_db', 'clean_index', 'harvest_setup', 'clean_queues')
@pytest.mark.usefixtures('with_plugins', 'clean_db', 'clean_index', 'clean_queues')
@pytest.mark.ckan_config('ckan.plugins', 'dcat harvest dcat_rdf_harvester')
class TestDCATHarvestFunctional(FunctionalHarvestTest):

Expand Down Expand Up @@ -1118,7 +1111,6 @@ def test_harvest_create_duplicate_titles(self):
'with_plugins',
'clean_db',
'clean_index',
'harvest_setup',
'clean_queues',
)
@pytest.mark.ckan_config('ckan.plugins', 'dcat harvest dcat_rdf_harvester test_rdf_harvester')
Expand Down Expand Up @@ -1547,7 +1539,6 @@ def test_harvest_import_extensions_point_gets_called(self, reset_calls_counter):
'with_plugins',
'clean_db',
'clean_index',
'harvest_setup',
'clean_queues',
)
@pytest.mark.ckan_config('ckan.plugins', 'dcat harvest dcat_rdf_harvester test_rdf_null_harvester')
Expand Down Expand Up @@ -1608,7 +1599,6 @@ def test_harvest_with_before_create_null(self, reset_calls_counter):
'with_plugins',
'clean_db',
'clean_index',
'harvest_setup',
'clean_queues',
)
@pytest.mark.ckan_config('ckan.plugins', 'dcat harvest dcat_rdf_harvester test_rdf_exception_harvester')
Expand Down
6 changes: 3 additions & 3 deletions ckanext/dcat/tests/test_json_harvester.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from ckanext.dcat.harvesters._json import copy_across_resource_ids, DCATJSONHarvester

from .test_harvester import FunctionalHarvestTest, harvest_setup, clean_queues
from .test_harvester import FunctionalHarvestTest, clean_queues


@pytest.mark.usefixtures('with_plugins', 'clean_db', 'clean_index', 'harvest_setup', 'clean_queues')
@pytest.mark.usefixtures('with_plugins', 'clean_db', 'clean_index', 'clean_queues')
@pytest.mark.ckan_config('ckan.plugins', 'dcat harvest dcat_json_harvester')
class TestDCATJSONHarvestFunctional(FunctionalHarvestTest):

Expand Down Expand Up @@ -284,7 +284,7 @@ def test_not_copied_because_completely_different(self):
)
assert harvested_dataset['resources'][0].get('id') == None

@pytest.mark.usefixtures('clean_db', 'clean_index', 'harvest_setup', 'clean_queues')
@pytest.mark.usefixtures('clean_db', 'clean_index', 'clean_queues')
class TestImportStage(object):

class MockHarvestObject(object):
Expand Down

0 comments on commit f147f21

Please sign in to comment.