Skip to content

Commit

Permalink
Refactor tests to avoid failures
Browse files Browse the repository at this point in the history
Caused by ckan/ckan#6880
  • Loading branch information
amercader committed Jul 14, 2022
1 parent 8ed1eca commit b92b364
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions ckanext/harvest/tests/test_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ def _assert_in_body(string, response):
@pytest.mark.usefixtures('clean_db', 'clean_index', 'harvest_setup')
class TestBlueprint():

def setup(self):
sysadmin = factories.Sysadmin()
self.extra_environ = {'REMOTE_USER': sysadmin['name'].encode('ascii')}

def test_index_page_is_rendered(self, app):

source1 = harvest_factories.HarvestSource()
Expand All @@ -33,8 +29,10 @@ def test_index_page_is_rendered(self, app):
def test_new_form_is_rendered(self, app):

url = url_for('harvest_new')
sysadmin = factories.Sysadmin()
env = {"REMOTE_USER": sysadmin['name'].encode('ascii')}

response = app.get(url, extra_environ=self.extra_environ)
response = app.get(url, extra_environ=env)

_assert_in_body('<form id="source-new"', response)

Expand All @@ -43,8 +41,10 @@ def test_edit_form_is_rendered(self, app):
source = harvest_factories.HarvestSource()

url = url_for('harvest_edit', id=source['id'])
sysadmin = factories.Sysadmin()
env = {"REMOTE_USER": sysadmin['name'].encode('ascii')}

response = app.get(url, extra_environ=self.extra_environ)
response = app.get(url, extra_environ=env)

_assert_in_body('<form id="source-new"', response)

Expand All @@ -53,8 +53,10 @@ def test_source_page_rendered(self, app):
source = harvest_factories.HarvestSource()

url = url_for('harvest_read', id=source['name'])
sysadmin = factories.Sysadmin()
env = {"REMOTE_USER": sysadmin['name'].encode('ascii')}

response = app.get(url, extra_environ=self.extra_environ)
response = app.get(url, extra_environ=env)

_assert_in_body(source['name'], response)

Expand All @@ -79,8 +81,10 @@ def test_about_page_rendered(self, app):
source = harvest_factories.HarvestSource()

url = url_for('harvest_about', id=source['name'])
sysadmin = factories.Sysadmin()
env = {"REMOTE_USER": sysadmin['name'].encode('ascii')}

response = app.get(url, extra_environ=self.extra_environ)
response = app.get(url, extra_environ=env)

_assert_in_body(source['name'], response)

Expand Down Expand Up @@ -116,7 +120,9 @@ def test_job_show_page_rendered(self, app):

url = url_for(
'harvest_job_show', source=job['source_id'], id=job['id'])
sysadmin = factories.Sysadmin()
env = {"REMOTE_USER": sysadmin['name'].encode('ascii')}

response = app.get(url, extra_environ=self.extra_environ)
response = app.get(url, extra_environ=env)

_assert_in_body(job['id'], response)

0 comments on commit b92b364

Please sign in to comment.