From 605febf1b74bac0fb31f4759c6eb24ee182fa4b1 Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 11 Apr 2017 10:13:42 +0100 Subject: [PATCH] [#3229] Fix url_for test --- ckanext/datapusher/tests/test_action.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) 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)