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


Ignore:
Timestamp:
Dec 21, 2018, 11:11:44 AM (5 years ago)
Author:
borja <borja@…>
Branches:
current, feature/docs, master
Children:
64e8299
Parents:
31adfa5
Message:

Tests and coverage catch up.

File:
1 edited

Legend:

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

    r31adfa5 rfe6089a  
    164164        assert len(response['form'].form.errors) == 1
    165165
     166    def test_add_workout_post_invalid_bytes(self, dummy_request):
     167        """
     168        POST request to add a workout, without uploading a tracking file,
     169        which sends an empty bytes object (b'')
     170        """
     171        request = dummy_request
     172        user = request.root['john']
     173        request.method = 'POST'
     174        request.POST = MultiDict({
     175            'tracking_file': b'',
     176            'submit': True,
     177            })
     178        assert len(request.root['john'].workouts()) == 1
     179        response = workout_views.add_workout(user, request)
     180        assert 'form' in response
     181        # Only one required field in this case, the tracking file
     182        assert len(response['form'].form.errors) == 1
     183
    166184    @pytest.mark.parametrize('filename', gpx_filenames)
    167185    def test_add_workout_post_valid(self, filename, dummy_request):
     
    256274        assert len(response['form'].form.errors) == 1
    257275
     276    def test_update_workout_from_file_post_invalid_bytes(self, dummy_request):
     277        """
     278        POST request to update a workout, without uploading a tracking file,
     279        which sends an empty bytes object (b'')
     280        """
     281        request = dummy_request
     282        user = request.root['john']
     283        workout = user.workouts()[0]
     284        request.method = 'POST'
     285        request.POST = MultiDict({
     286            'tracking_file': b'',
     287            'submit': True,
     288            })
     289        response = workout_views.update_workout_from_file(workout, request)
     290        assert 'form' in response
     291        # Only one required field in this case, the tracking file
     292        assert len(response['form'].form.errors) == 1
     293
    258294    @pytest.mark.parametrize('filen', gpx_filenames)
    259295    def test_update_workout_from_file_post_valid(self, filen, dummy_request):
Note: See TracChangeset for help on using the changeset viewer.