Skip to content

Commit

Permalink
test: update fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Nov 2, 2023
1 parent 227f240 commit 8e143e4
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 16 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Expand Up @@ -57,6 +57,5 @@ jobs:
- name: Setup extension (CKAN >= 2.9)
run: |
ckan -c test.ini db init
ckan -c test.ini harvester initdb
- name: Run tests
run: pytest --ckan-ini=test.ini --cov=ckanext.harvest --disable-warnings ckanext/harvest/tests
6 changes: 6 additions & 0 deletions ckanext/harvest/tests/conftest.py
@@ -0,0 +1,6 @@
import pytest

@pytest.fixture
def clean_db(reset_db, migrate_db_for):
reset_db()
migrate_db_for("harvest")
6 changes: 0 additions & 6 deletions ckanext/harvest/tests/fixtures.py
@@ -1,14 +1,8 @@
import pytest

import ckanext.harvest.model as harvest_model
from ckanext.harvest import queue


@pytest.fixture
def harvest_setup():
harvest_model.setup()


@pytest.fixture
def clean_queues():
queue.purge_queues()
4 changes: 2 additions & 2 deletions ckanext/harvest/tests/harvesters/test_base.py
Expand Up @@ -13,7 +13,7 @@
_ensure_name_is_unique = HarvesterBase._ensure_name_is_unique


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

def test_basic(self):
Expand Down Expand Up @@ -51,7 +51,7 @@ def test_config_override(self):
assert HarvesterBase._gen_new_name('Trees', append_type='number-sequence') == 'trees1'


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

def test_no_existing_datasets(self):
Expand Down
2 changes: 1 addition & 1 deletion ckanext/harvest/tests/harvesters/test_ckanharvester.py
Expand Up @@ -38,7 +38,7 @@ def was_last_job_considered_error_free():
return bool(HarvesterBase.last_error_free_job(job))


@pytest.mark.usefixtures('with_plugins', 'clean_db', 'clean_index', 'harvest_setup')
@pytest.mark.usefixtures('with_plugins', 'clean_db', 'clean_index')
class TestCkanHarvester(object):

def test_gather_normal(self):
Expand Down
4 changes: 2 additions & 2 deletions ckanext/harvest/tests/test_action.py
Expand Up @@ -57,7 +57,7 @@ def import_stage(self, harvest_object):
}


@pytest.mark.usefixtures('with_plugins', 'clean_db', 'harvest_setup', 'clean_queues')
@pytest.mark.usefixtures('with_plugins', 'clean_db', 'clean_queues')
@pytest.mark.ckan_config('ckan.plugins', 'harvest test_action_harvester')
class HarvestSourceActionBase():

Expand Down Expand Up @@ -225,7 +225,7 @@ def test_patch(self):
assert source.type == source_dict['source_type']


@pytest.mark.usefixtures('with_plugins', 'clean_db', 'harvest_setup', 'clean_queues')
@pytest.mark.usefixtures('with_plugins', 'clean_db', 'clean_queues')
@pytest.mark.ckan_config('ckan.plugins', 'harvest test_action_harvester')
class TestActions():
def test_harvest_source_clear(self):
Expand Down
2 changes: 1 addition & 1 deletion ckanext/harvest/tests/test_blueprint.py
Expand Up @@ -5,7 +5,7 @@
from ckanext.harvest.tests import factories as harvest_factories


@pytest.mark.usefixtures('clean_db', 'clean_index', 'harvest_setup')
@pytest.mark.usefixtures('clean_db', 'clean_index')
class TestBlueprint():

def test_index_page_is_rendered(self, app):
Expand Down
2 changes: 1 addition & 1 deletion ckanext/harvest/tests/test_queue.py
Expand Up @@ -88,7 +88,7 @@ def import_stage(self, harvest_object):
return True


@pytest.mark.usefixtures('with_plugins', 'clean_db', 'harvest_setup', 'clean_queues')
@pytest.mark.usefixtures('with_plugins', 'clean_db', 'clean_queues')
@pytest.mark.ckan_config('ckan.plugins', 'harvest test_harvester')
class TestHarvestQueue(object):

Expand Down
2 changes: 1 addition & 1 deletion ckanext/harvest/tests/test_queue2.py
Expand Up @@ -84,7 +84,7 @@ def import_stage(self, harvest_object):
return True


@pytest.mark.usefixtures('with_plugins', 'clean_db', 'harvest_setup', 'clean_queues')
@pytest.mark.usefixtures('with_plugins', 'clean_db', 'clean_queues')
@pytest.mark.ckan_config('ckan.plugins', 'harvest test_harvester2')
class TestEndStates(object):

Expand Down
2 changes: 1 addition & 1 deletion ckanext/harvest/tests/test_timeouts.py
Expand Up @@ -9,7 +9,7 @@
from ckanext.harvest.logic import HarvestJobExists


@pytest.mark.usefixtures('with_plugins', 'clean_db', 'harvest_setup', 'clean_queues')
@pytest.mark.usefixtures('with_plugins', 'clean_db', 'clean_queues')
@pytest.mark.ckan_config('ckan.plugins', 'harvest test_action_harvester')
class TestModelFunctions:
dataset_counter = 0
Expand Down

0 comments on commit 8e143e4

Please sign in to comment.