From 264e7132dd6f4ca5c24ae54b851b61c89c70e78a Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Fri, 15 Jan 2021 08:15:35 +0100 Subject: [PATCH] fixing mock session --- rowers/tests/mocks.py | 10 ++++++++++ rowers/tests/test_imports.py | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/rowers/tests/mocks.py b/rowers/tests/mocks.py index a1199487..e5d8654a 100644 --- a/rowers/tests/mocks.py +++ b/rowers/tests/mocks.py @@ -657,6 +657,16 @@ def mocked_requests(*args, **kwargs): class MockSession: + class headers: + def __init__(self,*args,**kwargs): + pass + + def update(self,*args,**kwargs): + pass + + def post(self, *args, **kwargs): + return MockResponse('',200) + def send(self,prepped): # prepped.url # prepped.body (post data) diff --git a/rowers/tests/test_imports.py b/rowers/tests/test_imports.py index 1c4cf58b..88ab58ec 100644 --- a/rowers/tests/test_imports.py +++ b/rowers/tests/test_imports.py @@ -117,7 +117,8 @@ class GarminObjects(DjangoTestCase): self.assertEqual(response.status_code,200) @patch('rowers.tasks.OAuth1Session',side_effect=mocked_requests) - def test_handle_get_garmin_file(self, MockOAuth1Session): + @patch('rowers.tasks.requests.session', side_effect=mocked_requests) + def test_handle_get_garmin_file(self, MockSession, MockOAuth1Session): client_id = 'garmin' client_secret = 'noot' garmintoken = 'mies'