diff --git a/ckanext/datapusher/tests/test_action.py b/ckanext/datapusher/tests/test_action.py index 52f1e75bd6e..b3bacf95c73 100644 --- a/ckanext/datapusher/tests/test_action.py +++ b/ckanext/datapusher/tests/test_action.py @@ -13,6 +13,9 @@ class TestDataPusherAction(object): @classmethod def setup_class(cls): + + cls.app = helpers._get_test_app() + if not p.plugin_loaded('datastore'): p.load('datastore') if not p.plugin_loaded('datapusher'): @@ -288,12 +291,15 @@ def submit(res, user): user = factories.User() res = factories.Resource(user=user) - with mock.patch('requests.post') as r_mock: - r_mock().json = mock.Mock( - side_effect=lambda: dict.fromkeys( - ['job_id', 'job_key'])) - r_mock.reset_mock() - submit(res, user) - submit(res, user) - - eq_(1, r_mock.call_count) + + with self.app.flask_app.test_request_context(): + with mock.patch('requests.post') as r_mock: + r_mock().json = mock.Mock( + side_effect=lambda: dict.fromkeys( + ['job_id', 'job_key'])) + r_mock.reset_mock() + + submit(res, user) + submit(res, user) + + eq_(1, r_mock.call_count)