diff --git a/rowers/tests.py b/rowers/tests.py index cb0a0591..1171ada4 100644 --- a/rowers/tests.py +++ b/rowers/tests.py @@ -60,8 +60,12 @@ def mocked_requests(*args, **kwargs): with open('rowers/testdata/c2jsonstrokedata.txt','r') as infile: c2strokedata = json.load(infile) + polar_json = { + 'available-user-data': [] + } + c2workoutlist = json.load(open('rowers/testdata/c2workoutlist.txt')) - + c2uploadjson = { "data": { "id": 339, @@ -152,6 +156,7 @@ def mocked_requests(*args, **kwargs): if not args: return MockSession() + polartester = re.compile('.*?polaraccesslink\.com') c2tester = re.compile('.*?log\.concept2\.com') stravatester = re.compile('.*?strava\.com') sttester = re.compile('.*?sporttracks\.mobi') @@ -214,6 +219,10 @@ def mocked_requests(*args, **kwargs): tpuploadregex = '.*?trainingpeaks\.com\/v1\/file' tpuploadtester = re.compile(tpuploadregex) + if polartester.match(args[0]): + json_data = polar_json + return MockResponse(json_data,200) + if tptester.match(args[0]): if 'token' in args[0]: json_data = { @@ -1068,8 +1077,8 @@ boattype: 4x if not os.path.isdir(path): os.remove(path) - @patch('rowers.c2stuff.requests.get', side_effect=mocked_requests) - def test_emailprocessing(self): + @patch('requests.get', side_effect=mocked_requests) + def test_emailprocessing(self, mock_get): out = StringIO() call_command('processemail', stdout=out,testing=True) self.assertIn('Successfully processed email attachments',out.getvalue())