Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelbabu committed Mar 23, 2013
1 parent fa48154 commit 4665000
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ckan/tests/functional/api/test_dashboard.py
Expand Up @@ -331,3 +331,22 @@ def test_09_activities_that_should_not_show(self):
after = self.dashboard_activity_list(self.new_user)

assert before == after

def test_10_dashboard_activity_list_html(self):
'''Test that dashboard activity list html call works.'''

This comment has been minimized.

Copy link
@seanh

seanh Apr 10, 2013

Contributor

This docstrings could be a little clearer, "works" is quite ambiguous. All this tests is that it returns successfully, Maybe ''Test that dashboard activity list html call doesn't crash.'' You could just rename the method to test_10_dashboard_activity_list_html_does_not_crash and then you wouldn't even need the docstring.


params = json.dumps({'name': 'irrelevant_dataset'})
response = self.app.post('/api/action/package_create', params=params,
extra_environ={'Authorization': str(self.annafan['apikey'])})
assert response.json['success'] is True

This comment has been minimized.

Copy link
@seanh

seanh Apr 10, 2013

Contributor

There's a shared test helper function for posting to the action api, which saves a lot of boilerplate: https://github.com/okfn/ckan/blob/master/ckan/tests/__init__.py#L411


params = json.dumps({'name': 'another_irrelevant_dataset'})
response = self.app.post('/api/action/package_create', params=params,
extra_environ={'Authorization': str(self.annafan['apikey'])})
assert response.json['success'] is True

res = self.app.get('/api/3/action/dashboard_activity_list_html',
extra_environ={'Authorization':
str(self.annafan['apikey'])})
print res.json['result']

This comment has been minimized.

Copy link
@seanh

seanh Apr 10, 2013

Contributor

You need to get rid of this print statement. Checkout out ipdb and the ipdb nose plugin, they can be useful for debugging without putting print statements in

assert res.json['success'] is True

0 comments on commit 4665000

Please sign in to comment.