Skip to content

Commit

Permalink
[QOLDEV-1011] mock out global object during auth test
Browse files Browse the repository at this point in the history
  • Loading branch information
ThrawnCA committed Nov 15, 2024
1 parent 57fb298 commit 1669f5a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ckanext/datarequests/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ class AuthTest(unittest.TestCase):
def setUp(self):
self._get_action = auth.get_action
auth.get_action = MagicMock()
self._g = controller_functions.g
controller_functions.g = MagicMock()

def tearDown(self):
auth.get_action = self._get_action
controller_functions.g = self._g

@parameterized.expand([
# Data Requests
Expand Down
5 changes: 1 addition & 4 deletions ckanext/datarequests/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@ def setUp(self):
self.db_patch = patch('ckanext.datarequests.helpers.db')
self.db_patch.start()

self._c = helpers.c
helpers.c = MagicMock()
helpers.c.userobj.id = '12345'
helpers.tk.g.userobj.id = '12345'

def tearDown(self):
self.tk_patch.stop()
self.db_patch.stop()
helpers.c = self._c

def test_get_comments_number(self):
# Mocking
Expand Down

0 comments on commit 1669f5a

Please sign in to comment.