def test_upload_image(client, mocker):
    today = datetime.date.today()
    mocker.patch('requests.get')
    mocker.patch('redwind.tasks.create_queue')

    rv = client.post('/save_new', data={
        'photo': (open('tests/image.jpg', 'rb'), 'image.jpg', 'image/jpeg'),
        'post_type': 'photo',
        'content': 'High score',
        'action': 'publish_quietly',
    })

    assert rv.status_code == 302
    assert (rv.location == 'http://example.com/{}/{:02d}/high-score'.format(
        today.year, today.month))
    permalink = rv.location

    rv = client.get(permalink)
    assert rv.status_code == 200
    content = rv.get_data(as_text=True)

    assert 'High score' in content
    assert content in '<img'

    rv = client.get(permalink + '/files/image.jpg')
    assert rv.status_code == 200
    # Removed depndency on PIL
    # im = Image.open(io.BytesIO(rv.data))
    # assert im.size[0] > 300 or im.size[1] > 300

    # FIXME resizing depends on an external service now;
    #       we can only test that the proper url is constructed
    # rv = client.get(permalink + '/files/image.jpg',
    #                 query_string={'size': 'small'})
    # assert rv.status_code == 200
    # im = Image.open(io.BytesIO(rv.data))
    # assert im.size[0] <= 300 and im.size[1] <= 300
dataset/ETHPy150Open kylewm/redwind/tests/views_test.py/test_upload_image/swapped operands of `in`