Changeset 0dedfbe in OpenWorkouts-current for ow/tests/models/test_root.py


Ignore:
Timestamp:
Apr 22, 2019, 10:47:55 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current
Children:
a6fa857
Parents:
42baca4
Message:

(#39) Duplicated workouts, fixed broken tests, added more tests coverage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/tests/models/test_root.py

    r42baca4 r0dedfbe  
    22from unittest.mock import Mock
    33from datetime import datetime, timedelta, timezone
     4from decimal import Decimal
    45
    56import pytest
     
    175176        john.add_workout(workout)
    176177        assert root.sports_json == json.dumps(["cycling", "running"])
     178
     179    def test_get_workout_by_hash(self, root, john):
     180        # non existant hash
     181        found = root.get_workout_by_hash('non-existant-hash')
     182        assert found is None
     183        # existing workout
     184        workout = root[str(john.uid)]['1']
     185        found = root.get_workout_by_hash(workout.hashed)
     186        assert found == workout
     187        # a workout that was not added to the system
     188        workout = Workout(
     189            start_time=datetime.now(timezone.utc),
     190            duration=timedelta(seconds=3600),
     191            distance=Decimal(30)
     192        )
     193        found = root.get_workout_by_hash(workout.hashed)
     194        assert found is None
Note: See TracChangeset for help on using the changeset viewer.