Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

Commit

Permalink
fix for #23: added missing import and improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
podusowski committed May 12, 2017
1 parent 90533dc commit 06748a1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions activities/gps/endomondo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from training import models
from . import gpx
from . import gps_workout

@transaction.atomic
def _import_endomondo_workout(user, endomondo_workout):
Expand Down
31 changes: 31 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 06748a1

Please sign in to comment.