Changeset e52a502 in OpenWorkouts-current for ow/tests/views/test_workout.py


Ignore:
Timestamp:
Apr 19, 2019, 5:03:49 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current
Children:
42baca4
Parents:
39dc0a6
Message:

(#73) Fixed broken "add workout manually" when provided with a distance value
with decimals.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/tests/views/test_workout.py

    r39dc0a6 re52a502  
    55from cgi import FieldStorage
    66from unittest.mock import Mock, patch, PropertyMock
     7from decimal import Decimal
    78
    89import pytest
     
    131132        # no title, no sport, we generate a title based on when the
    132133        # workout started
    133         ({'title': None, 'sport': None}, 'Morning workout'),
     134        ({'title': None, 'sport': None},
     135         {'title': 'Morning workout',
     136          'distance': 10}),
    134137        # no title, sport given, we use the sport too in the automatically
    135138        # generated title
    136         ({'title': None, 'sport': 'cycling'}, 'Morning cycling workout'),
     139        ({'title': None, 'sport': 'cycling'},
     140         {'title': 'Morning cycling workout',
     141          'distance': 10}),
    137142        # title given, no sport, we use the provided title
    138         ({'title': 'Example workout', 'sport': None}, 'Example workout'),
     143        ({'title': 'Example workout', 'sport': None},
     144         {'title': 'Example workout',
     145          'distance': 10}),
    139146        # title given, sport too, we use the provided title
    140         ({'title': 'Example workout', 'sport': 'cycling'}, 'Example workout'),
     147        ({'title': 'Example workout', 'sport': 'cycling'},
     148         {'title': 'Example workout',
     149          'distance': 10}),
    141150    ]
    142151
     
    158167        assert response.location.endswith('/2/')
    159168        assert len(user.workouts()) == 2
    160         assert user['2'].title == expected
     169        assert user['2'].title == expected['title']
     170        assert isinstance(user['2'].distance, Decimal)
     171        assert user['2'].distance == Decimal(expected['distance'])
    161172
    162173    def test_add_workout_get(self, dummy_request):
Note: See TracChangeset for help on using the changeset viewer.