Skip to content

Commit

Permalink
[#4332] Fix datastore "dictionary" tab render
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed Jul 27, 2018
1 parent 600be27 commit 52bcabb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ckanext/datastore/controller.py
Expand Up @@ -109,7 +109,10 @@ def dictionary(self, id, resource_id):

return render(
'datastore/dictionary.html',
extra_vars={'fields': fields})
extra_vars={
'fields': fields,
'resource': c.resource,
})


def dump_to(resource_id, output, fmt, offset, limit, options):
Expand Down
35 changes: 35 additions & 0 deletions ckanext/datastore/tests/test_dictionary.py
@@ -0,0 +1,35 @@
from ckanext.datastore.tests.helpers import DatastoreFunctionalTestBase, DatastoreLegacyTestBase
import ckan.tests.factories as factories
import ckan.tests.helpers as helpers


class TestDatastoreDictionary(DatastoreLegacyTestBase):

@classmethod
def setup_class(cls):
cls.app = helpers._get_test_app()
super(TestDatastoreDictionary, cls).setup_class()

def test_read(self):
user = factories.User()
dataset = factories.Dataset(creator_user_id=user['id'])
resource = factories.Resource(package_id=dataset['id'],
creator_user_id=user['id'])
data = {
'resource_id': resource['id'],
'force': True,
'records': [
{'from': 'Brazil', 'to': 'Brazil', 'num': 2},
{'from': 'Brazil', 'to': 'Italy', 'num': 22}
],
}
helpers.call_action('datastore_create', **data)
auth = {'Authorization': str(user['apikey'])}
self.app.get(
# url='resource_dictionary',
# params=dict(id=str(dataset['name']),
# resource_id=str(resource['id'])),
url='/dataset/{id}/dictionary/{resource_id}'
.format(id=str(dataset['name']),
resource_id=str(resource['id'])),
extra_environ=auth)

0 comments on commit 52bcabb

Please sign in to comment.