Changeset 778d53d in OpenWorkouts-current for ow/tests/views/test_user.py


Ignore:
Timestamp:
Mar 5, 2019, 11:45:32 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current
Children:
aa6dcaf
Parents:
35953eb
Message:

(#7) Show per-sport stats in the profile page:

  • Show a dropdown list of sports for which the user has activities. By default we choose the sport with most activities.
  • Show a dropdown list of years for which the user has activities. By default we show stats for the current year. If the user picks up a different year, we show the totals (distance, time, elevation, number of workouts) for that year.
  • Show the totals of all time for the chosen sport
File:
1 edited

Legend:

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

    r35953eb r778d53d  
    4646            start=datetime(2015, 6, 28, 12, 55, tzinfo=timezone.utc),
    4747            duration=timedelta(minutes=60),
    48             distance=30
     48            distance=30,
     49            sport='cycling'
    4950        )
    5051        john.add_workout(workout)
     
    413414        # profile page for the current day (no workouts avalable)
    414415        response = user_views.profile(john, request)
    415         assert len(response.keys()) == 6
     416        assert len(response.keys()) == 7
    416417        current_month = datetime.now(timezone.utc).strftime('%Y-%m')
    417418        assert response['user'] == john
     
    425426            'elevation': Decimal(0)
    426427        }
     428        assert response['profile_stats'] == {
     429            'sports': ['cycling'],
     430            'years': [2015],
     431            'current_year': datetime.now(timezone.utc).year,
     432            'current_sport': 'cycling'
     433        }
    427434        # profile page for a previous date, that has workouts
    428435        request.GET['year'] = 2015
    429436        request.GET['month'] = 6
    430437        response = user_views.profile(john, request)
    431         assert len(response.keys()) == 6
     438        assert len(response.keys()) == 7
    432439        assert response['user'] == john
    433440        assert response['user_gender'] == 'Robot'
     
    446453        request.GET['week'] = 25
    447454        response = user_views.profile(john, request)
    448         assert len(response.keys()) == 6
     455        assert len(response.keys()) == 7
    449456        assert response['user'] == john
    450457        assert response['user_gender'] == 'Robot'
     
    462469        request.GET['week'] = 26
    463470        response = user_views.profile(john, request)
    464         assert len(response.keys()) == 6
     471        assert len(response.keys()) == 7
    465472        assert response['user'] == john
    466473        assert response['user_gender'] == 'Robot'
Note: See TracChangeset for help on using the changeset viewer.