Skip to content

Commit

Permalink
Test results if no preview is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Nov 8, 2012
1 parent 600ac9f commit abf5e25
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ckan/tests/functional/test_preview_interface.py
Expand Up @@ -63,9 +63,17 @@ def test_hook(self):
'user': model.User.get('testsysadmin').name
}

# no preview for type "plain text"
preview_url = h.url_for(controller='package',
action='resource_datapreview',
id=testpackage.id,
resource_id=testpackage.resources[0].id)
result = self.app.get(preview_url, status=409)
assert 'No preview' in result.body, result.body

l.action.update.resource_update(context, resource_dict)
print testpackage.resources[0].format

#there should be a preview for type "json"
preview_url = h.url_for(controller='package',
action='resource_datapreview',
id=testpackage.id,
Expand All @@ -75,10 +83,11 @@ def test_hook(self):
assert 'mock-preview' in result.body
assert 'mock-preview.js' in result.body

assert self.plugin.calls['can_preview'] == 1, self.plugin.calls
assert self.plugin.calls['can_preview'] == 2, self.plugin.calls
assert self.plugin.calls['setup_template_variables'] == 1, self.plugin.calls
assert self.plugin.calls['preview_templates'] == 1, self.plugin.calls

# test whether the json preview is used
preview_url = h.url_for(controller='package',
action='resource_datapreview',
id=testpackage.id,
Expand All @@ -88,6 +97,6 @@ def test_hook(self):
assert 'mock-json-preview' in result.body
assert 'mock-json-preview.js' in result.body

assert self.plugin.calls['can_preview'] == 2, self.plugin.calls
assert self.plugin.calls['can_preview'] == 3, self.plugin.calls
assert self.plugin.calls['setup_template_variables'] == 1, self.plugin.calls
assert self.plugin.calls['preview_templates'] == 1, self.plugin.calls

0 comments on commit abf5e25

Please sign in to comment.