Пример #1
0
def execute_if_complete(pending_request):
    if pending_request.pendingverification_set.count():
        return False
    serializer = UpdateRequestSerializer(data=pending_request.request)
    serializer.is_valid(True)
    request = serializer.save()
    request.execute()
    pending_request.delete()
    return True
Пример #2
0
def execute_if_complete(pending_request):
    if pending_request.pendingverification_set.count():
        return False
    serializer = UpdateRequestSerializer(data=pending_request.request)
    serializer.is_valid(True)
    request = serializer.save()
    request.execute()
    pending_request.delete()
    return True
Пример #3
0
def test_invalid_field(simple_identity):
    request = {
        'identity': simple_identity,
        'items': [
            make_update_item('emailx', '*****@*****.**'),
        ]
    }
    serializer = UpdateRequestSerializer(data=request)
    assert not serializer.is_valid()
Пример #4
0
def test_similar_items(simple_identity):
    request = {
        'identity': simple_identity,
        'items': [
            make_update_item('email', '*****@*****.**'),
            make_update_item('email', '*****@*****.**', action='delete')
        ]
    }
    serializer = UpdateRequestSerializer(data=request)
    assert serializer.is_valid(), serializer.errors
Пример #5
0
def test_plural_items(simple_identity):
    request = {
        'identity': simple_identity,
        'items': [
            make_update_item('email', '*****@*****.**'),
            make_update_item('email', '*****@*****.**'),
        ]
    }
    serializer = UpdateRequestSerializer(data=request)
    assert not serializer.is_valid()
    assert 'Duplicate field/action is not allowed: create, email' in serializer.errors['items']
Пример #6
0
def test_identical_items(simple_identity):
    request = {
        'identity': simple_identity,
        'items': [
            make_update_item('email', '*****@*****.**'),
            make_update_item('email', '*****@*****.**')
        ]
    }
    serializer = UpdateRequestSerializer(data=request)
    assert not serializer.is_valid()
    assert 'Duplicate update items are not allowed.' in serializer.errors['items']
Пример #7
0
def test_single_item(simple_identity):
    request = {
        'identity': simple_identity,
        'items': [make_update_item('email', '*****@*****.**')]
    }
    serializer = UpdateRequestSerializer(data=request)
    assert serializer.is_valid(), serializer.errors
    update_request = serializer.save()
    assert len(update_request.items) == 1
    identity = update_request.identity
    assert identity.public_key == simple_identity['public_key']
    assert identity.drop_url == simple_identity['drop_url']
    assert identity.alias == simple_identity['alias']
    item = update_request.items[0]
    assert item.action == 'create'
    assert item.field == 'email'
    assert item.value == '*****@*****.**'
Пример #8
0
def test_invalid_request(invalid):
    serializer = UpdateRequestSerializer(data=invalid)
    assert not serializer.is_valid()