def test_player_icon_not_required_for_update(factories):
    player = factories.PlayerFactory(name='Initial')
    serializer = PlayerSerializer(player, data={
        'name': 'Updated',
    })
    assert serializer.is_valid(), serializer.errors
    updated_player = serializer.save()

    assert updated_player.name == 'Updated'
    assert player.icon.name == updated_player.icon.name
def test_player_icon_not_required_for_update(factories):
    player = factories.PlayerFactory(name='Initial')
    serializer = PlayerSerializer(player, data={
        'name': 'Updated',
    })
    assert serializer.is_valid(), serializer.errors
    updated_player = serializer.save()

    assert updated_player.name == 'Updated'
    assert player.icon.name == updated_player.icon.name
def test_new_player_creation():
    serializer = PlayerSerializer(data={
        'icon_filename': 'yoav.jpg',
        'icon': base64.b64encode(open('tests/yoav.jpg', 'r').read()),
        'name': 'Yoav',
    })
    assert serializer.is_valid(), serializer.errors
    player = serializer.save()
    assert player.name == 'Yoav'
    assert player.icon is not None
    assert player.icon.width == 400
    assert player.icon.height == 400
def test_new_player_creation():
    serializer = PlayerSerializer(
        data={
            'icon_filename': 'yoav.jpg',
            'icon': base64.b64encode(open('tests/yoav.jpg', 'r').read()),
            'name': 'Yoav',
        })
    assert serializer.is_valid(), serializer.errors
    player = serializer.save()
    assert player.name == 'Yoav'
    assert player.icon is not None
    assert player.icon.width == 400
    assert player.icon.height == 400