Skip to content

Commit

Permalink
Instead of importing NotAuthorized in test helpers, do it on the test…
Browse files Browse the repository at this point in the history
… file
  • Loading branch information
vitorbaptista authored and amercader committed Jun 19, 2014
1 parent 9c9481c commit c289662
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 0 additions & 3 deletions ckan/new_tests/helpers.py
Expand Up @@ -21,9 +21,6 @@
import ckan.logic as logic


NotAuthorized = logic.NotAuthorized


def reset_db():
'''Reset CKAN's database.
Expand Down
7 changes: 4 additions & 3 deletions ckan/new_tests/logic/auth/test_update.py
Expand Up @@ -6,6 +6,7 @@

import ckan.new_tests.helpers as helpers
import ckan.new_tests.factories as factories
import ckan.logic as logic


class TestUpdate(object):
Expand Down Expand Up @@ -34,7 +35,7 @@ def test_user_update_visitor_cannot_update_user(self):
'name': 'updated_user_name',
}

with nose.tools.assert_raises(helpers.NotAuthorized) as cm:
with nose.tools.assert_raises(logic.NotAuthorized) as cm:
helpers.call_auth('user_update', context=context, **params)

assert cm.exception.extra_msg == ('User 127.0.0.1 not authorized to '
Expand Down Expand Up @@ -72,7 +73,7 @@ def test_user_update_user_cannot_update_another_user(self):

# 3. Make assertions about the return value and/or side-effects.

with nose.tools.assert_raises(helpers.NotAuthorized) as cm:
with nose.tools.assert_raises(logic.NotAuthorized) as cm:
helpers.call_auth('user_update', context=context, **params)

assert cm.exception.extra_msg == ('User bob not authorized to edit '
Expand Down Expand Up @@ -131,7 +132,7 @@ def test_user_update_with_no_user_in_context(self):
'id': mock_user.id,
'name': 'updated_user_name',
}
with nose.tools.assert_raises(helpers.NotAuthorized) as cm:
with nose.tools.assert_raises(logic.NotAuthorized) as cm:
helpers.call_auth('user_update', context=context, **params)

assert cm.exception.extra_msg == 'Have to be logged in to edit user'
Expand Down

0 comments on commit c289662

Please sign in to comment.