This repository has been archived by the owner on Aug 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix for #23: added missing import and improve test coverage
- Loading branch information
1 parent
90533dc
commit 06748a1
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,6 +231,37 @@ def test_import_from_endomondo_no_workouts(self): | |
statistics = self._get_statistics_from_dashboard() | ||
self.assertEqual(0, len(statistics.previous_workouts())) | ||
|
||
def test_import_many_workouts_from_endomondo(self): | ||
|
||
def make_endomondo_workout(i): | ||
|
||
class EndomondoWorkout: | ||
pass | ||
|
||
workout = EndomondoWorkout() | ||
workout.id = i | ||
workout.sport = "running" | ||
workout.distance = 10 | ||
workout.start_time = time(2016, 1, 1, 0, 0, 0) | ||
workout.duration = datetime.timedelta(seconds=i) | ||
workout.points = [] | ||
|
||
return workout | ||
|
||
with patch('endoapi.endomondo.Endomondo', autospec=True) as endomondo: | ||
endomondo.return_value = Mock() | ||
endomondo.return_value.token = 'token' | ||
|
||
self.post('/gps/endomondo/', {'email': '[email protected]', 'password': 'haslo'}) | ||
|
||
endomondo.return_value.fetch.return_value = [make_endomondo_workout(i) for i in range(10)] | ||
self.get('/gps/synchronize_endomondo_ajax/') | ||
|
||
endomondo.return_value.fetch.assert_called_once_with(max_results=10, before=None, after=None) | ||
|
||
statistics = self._get_statistics_from_dashboard() | ||
self.assertEqual(10, len(statistics.previous_workouts())) | ||
|
||
def _find_statistics_field(self, name, field): | ||
statistics = self._get_statistics_from_dashboard() | ||
workout_statistics = statistics.workout_statistics(name) | ||
|