Skip to content

Commit

Permalink
Undo change to fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
jguo144 committed Oct 4, 2024
1 parent acd3980 commit 4fecab7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ckanext/xloader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def load_csv(csv_filepath, resource_id, mimetype='text/csv', logger=None):
return fields, is_data_dict_populated

def _is_data_dict_populated(fields, logger):
"""Return True if the data_dict has been populated with the fields"""
"""Return True if the data dictionary has been populated"""
if (any((field for field in fields if field.get('info', {}).get('label'))) or
any((field for field in fields if field.get('info', {}).get('notes'))) or
any((field for field in fields if field.get('info', {}).get('type_override')))):
Expand Down
23 changes: 22 additions & 1 deletion ckanext/xloader/tests/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from sqlalchemy import orm
import os
import pytest

from ckanext.datastore.tests import helpers as datastore_helpers
from ckanext.xloader.loader import get_write_engine

Expand Down Expand Up @@ -99,6 +99,27 @@ def reset_index():
"""
return search.clear_all

@pytest.fixture
def clean_db(reset_db):
"""Resets the database to the initial state.
This can be used either for all tests in a class::
@pytest.mark.usefixtures("clean_db")
class TestExample(object):
def test_example(self):
or for a single test::
class TestExample(object):
@pytest.mark.usefixtures("clean_db")
def test_example(self):
"""
reset_db()

@pytest.fixture
def clean_index(reset_index):
"""Clear search index before starting the test.
Expand Down

0 comments on commit 4fecab7

Please sign in to comment.