Skip to content

Commit

Permalink
[#4332] Fix datapusher "DataStore" tab render following template changes
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed Jul 27, 2018
1 parent e1dafe6 commit 1e2a913
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ckanext/datapusher/plugin.py
Expand Up @@ -68,7 +68,11 @@ def resource_data(self, id, resource_id):
base.abort(403, _('Not authorized to see this page'))

return base.render('datapusher/resource_data.html',
extra_vars={'status': datapusher_status})
extra_vars={
'status': datapusher_status,
'pkg_dict': toolkit.c.pkg_dict,
'resource': toolkit.c.resource,
})


class DatapusherPlugin(p.SingletonPlugin):
Expand Down
44 changes: 44 additions & 0 deletions ckanext/datapusher/tests/test_controller.py
@@ -0,0 +1,44 @@
import nose
import sqlalchemy.orm as orm

import ckan.plugins as p
import ckan.tests.legacy as tests
from ckan.tests import helpers
import ckan.tests.factories as factories

import ckanext.datastore.backend.postgres as db
from ckanext.datastore.tests.helpers import rebuild_all_dbs, set_url_type


class TestController():
sysadmin_user = None
normal_user = None

@classmethod
def setup_class(cls):
cls.app = helpers._get_test_app()
if not tests.is_datastore_supported():
raise nose.SkipTest("Datastore not supported")
p.load('datastore')
p.load('datapusher')
engine = db.get_write_engine()
cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))

@classmethod
def teardown_class(cls):
rebuild_all_dbs(cls.Session)
p.unload('datastore')
p.unload('datapusher')

def test_resource_data(self):
user = factories.User()
dataset = factories.Dataset(creator_user_id=user['id'])
resource = factories.Resource(package_id=dataset['id'],
creator_user_id=user['id'])
auth = {'Authorization': str(user['apikey'])}

self.app.get(
url='/dataset/{id}/resource_data/{resource_id}'
.format(id=str(dataset['name']),
resource_id=str(resource['id'])),
extra_environ=auth)

0 comments on commit 1e2a913

Please sign in to comment.