Changes in ow/tests/views/test_user.py [bddf042:f0e64eb] in OpenWorkouts-current


Ignore:
File:
1 edited

Legend:

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

    rbddf042 rf0e64eb  
    55from shutil import copyfileobj
    66from unittest.mock import Mock, patch
     7from io import BytesIO
    78
    89import pytest
     
    1516
    1617from webob.multidict import MultiDict
     18
     19from PIL import Image
    1720
    1821from ow.models.root import OpenWorkouts
     
    417420        assert response.status_int == 200
    418421        assert response.content_type == 'image'
     422        # as we did not pass a specific size as a get parameter, the size is
     423        # the same as the original image
     424        original_image = Image.open(image_path)
     425        returned_image = Image.open(BytesIO(response.body))
     426        assert original_image.size == returned_image.size
     427
     428        # now, ask for a smaller image
     429        request.GET['size'] = original_image.size[0] - 20
     430        response = user_views.profile_picture(user, request)
     431        assert isinstance(response, Response)
     432        assert response.status_int == 200
     433        assert response.content_type == 'image'
     434        # now the size of the original image is bigger
     435        returned_image = Image.open(BytesIO(response.body))
     436        assert original_image.size > returned_image.size
     437
     438        # now, ask for a size that is bigger than the original image,
     439        # image will be the same size, as we do not "grow" its size
     440        request.GET['size'] = original_image.size[0] + 1000
     441        response = user_views.profile_picture(user, request)
     442        assert isinstance(response, Response)
     443        assert response.status_int == 200
     444        assert response.content_type == 'image'
     445        # now the size of the original image is bigger
     446        returned_image = Image.open(BytesIO(response.body))
     447        assert original_image.size == returned_image.size
     448
    419449
    420450    def test_edit_profile_get(self, dummy_request, john):
Note: See TracChangeset for help on using the changeset viewer.