Changeset 6211162 in OpenWorkouts-current


Ignore:
Timestamp:
Oct 13, 2019, 4:45:30 PM (3 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current
Children:
8340661
Parents:
93b23a6
Message:

Put duration/distance on the workout hash only if those values are there

Location:
ow
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ow/models/workout.py

    r93b23a6 r6211162  
    145145            hashed += str(self.owner.uid)
    146146        hashed += self.start.strftime('%Y%m%d%H%M%S')
    147         hashed += str(self.duration.seconds)
    148         hashed += str(self.distance)
     147        if self.duration is not None:
     148            hashed += str(self.duration.seconds)
     149        if self.distance is not None:
     150            hashed += str(self.distance)
    149151        return hashed
    150152
  • ow/tests/models/test_workout.py

    r93b23a6 r6211162  
    155155        # now a workout that is not (no owner info)
    156156        workout = Workout(
     157            sport='running',
    157158            start_time=datetime.now(timezone.utc),
    158159            duration=timedelta(seconds=3600),
     
    166167        # now an empty workout...
    167168        workout = Workout()
    168         with pytest.raises(AttributeError):
    169             assert workout.hashed == (
    170                 workout.start.strftime('%Y%m%d%H%M%S') +
    171                 str(workout.duration.seconds) +
    172                 str(workout.distance)
    173             )
     169        assert workout.hashed == (
     170            workout.start.strftime('%Y%m%d%H%M%S')
     171        )
    174172
    175173    def test_trimmed_notes(self):
Note: See TracChangeset for help on using the changeset viewer.