Skip to content

Commit

Permalink
Fix datastore_create tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Sep 26, 2019
1 parent f1d921d commit 36753a2
Show file tree
Hide file tree
Showing 4 changed files with 944 additions and 509 deletions.
4 changes: 2 additions & 2 deletions ckan/tests/config/test_middleware.py
Expand Up @@ -288,7 +288,7 @@ def test_user_objects_in_g_anon_user(self, app):
extra_environ={u'REMOTE_USER': str(u'')},
)
assert flask.g.user == u''
assert flask.g.userobj == None
assert flask.g.userobj is None
assert flask.g.author == u'Unknown IP Address'
assert flask.g.remote_addr == u'Unknown IP Address'

Expand Down Expand Up @@ -349,7 +349,7 @@ def test_user_objects_in_c_anon_user(self, app):

# tmpl_context available on response
assert resp.tmpl_context.user == u''
assert resp.tmpl_context.userobj == None
assert resp.tmpl_context.userobj is None
assert resp.tmpl_context.author == u'Unknown IP Address'
assert resp.tmpl_context.remote_addr == u'Unknown IP Address'

Expand Down
4 changes: 4 additions & 0 deletions ckan/tests/pytest/fixtures.py
Expand Up @@ -26,24 +26,28 @@ def make_app(ckan_config):
"""
return test_helpers._get_test_app


@pytest.fixture
def app(make_app):
"""Instance of client app.
"""
return make_app()


@pytest.fixture
def reset_db():
"""Clear database.
"""
test_helpers.reset_db()


@pytest.fixture
def reset_index():
"""Clear search index.
"""
search.clear_all()


@pytest.fixture
def reset_all(reset_db, reset_index):
"""Clear database and search index.
Expand Down
10 changes: 10 additions & 0 deletions ckanext/datastore/tests/conftest.py
@@ -0,0 +1,10 @@
import pytest
import ckanext.datastore.tests.helpers as test_helpers


@pytest.fixture
def reset_all(reset_all):
engine = test_helpers.db.get_write_engine()
test_helpers.rebuild_all_dbs(
test_helpers.orm.scoped_session(
test_helpers.orm.sessionmaker(bind=engine)))

0 comments on commit 36753a2

Please sign in to comment.