Changeset 6edc367 in OpenWorkouts-current for ow/tests/views/test_user.py
- Timestamp:
- Feb 8, 2019, 5:20:26 PM (5 years ago)
- Branches:
- current, feature/docs, master
- Children:
- 4226ce0
- Parents:
- 2a71053 (diff), 55470f9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/tests/views/test_user.py
r2a71053 r6edc367 1 1 import os 2 2 import json 3 from decimal import Decimal 3 4 from datetime import datetime, timedelta, timezone 4 5 from shutil import copyfileobj … … 269 270 # profile page for the current day (no workouts avalable) 270 271 response = user_views.profile(john, request) 271 assert len(response.keys()) == 3272 assert len(response.keys()) == 4 272 273 current_month = datetime.now(timezone.utc).strftime('%Y-%m') 273 274 assert response['current_month'] == current_month 274 275 assert response['current_week'] is None 275 276 assert response['workouts'] == [] 277 assert response['totals'] == { 278 'distance': Decimal(0), 279 'time': timedelta(0), 280 'elevation': Decimal(0) 281 } 276 282 # profile page for a previous date, that has workouts 277 283 request.GET['year'] = 2015 278 request.GET['month'] = 8284 request.GET['month'] = 6 279 285 response = user_views.profile(john, request) 280 assert len(response.keys()) == 3281 assert response['current_month'] == '2015-0 8'286 assert len(response.keys()) == 4 287 assert response['current_month'] == '2015-06' 282 288 assert response['current_week'] is None 283 assert response['workouts'] == john.workouts(2015, 8) 289 workouts = john.workouts(2015, 6) 290 assert response['workouts'] == workouts 291 assert response['totals'] == { 292 'distance': workouts[0].distance, 293 'time': workouts[0].duration, 294 'elevation': Decimal(0) 295 } 284 296 # same, passing a week, first on a week without workouts 285 297 request.GET['year'] = 2015 286 request.GET['month'] = 8298 request.GET['month'] = 6 287 299 request.GET['week'] = 25 288 300 response = user_views.profile(john, request) 289 assert len(response.keys()) == 3290 assert response['current_month'] == '2015-0 8'291 assert response['current_week'] is25301 assert len(response.keys()) == 4 302 assert response['current_month'] == '2015-06' 303 assert response['current_week'] == 25 292 304 assert response['workouts'] == [] 293 # now in a week with workoutss 305 assert response['totals'] == { 306 'distance': Decimal(0), 307 'time': timedelta(0), 308 'elevation': Decimal(0) 309 } 310 # now in a week with workouts 294 311 request.GET['year'] = 2015 295 request.GET['month'] = 8312 request.GET['month'] = 6 296 313 request.GET['week'] = 26 297 314 response = user_views.profile(john, request) 298 assert len(response.keys()) == 3 299 assert response['current_month'] == '2015-08' 300 assert response['current_week'] is 26 301 assert response['workouts'] == john.workouts(2015, 8) 315 assert len(response.keys()) == 4 316 assert response['current_month'] == '2015-06' 317 assert response['current_week'] == 26 318 workouts = john.workouts(2015, 6) 319 assert response['workouts'] == workouts 320 assert response['totals'] == { 321 'distance': workouts[0].distance, 322 'time': workouts[0].duration, 323 'elevation': Decimal(0) 324 } 302 325 303 326 def test_login_get(self, dummy_request):
Note: See TracChangeset
for help on using the changeset viewer.