Exemplo n.º 1
0
def test_phone_item_international():
    serializer = UpdateItemSerializer(
        data=make_update_item('phone', '+631234'))
    assert serializer.is_valid(), serializer.errors
    item = serializer.save()
    assert item.field == 'phone'
    assert item.value == '+631234'
Exemplo n.º 2
0
def test_phone_item_international_request(locale, input, output):
    with translation.override(locale):
        serializer = UpdateItemSerializer(data=make_update_item('phone', input))
        assert serializer.is_valid(), serializer.errors
        item = serializer.save()
    assert item.field == 'phone'
    assert item.value == output
Exemplo n.º 3
0
def test_simple_item():
    serializer = UpdateItemSerializer(
        data=make_update_item('email', '*****@*****.**'))
    assert serializer.is_valid(), serializer.errors
    item = serializer.save()
    assert item.field == 'email'
    assert item.value == '*****@*****.**'
Exemplo n.º 4
0
def test_invalid_item(invalid):
    serializer = UpdateItemSerializer(data=invalid)
    assert not serializer.is_valid()
Exemplo n.º 5
0
def test_phone_item_blatantly_invalid():
    serializer = UpdateItemSerializer(data=make_update_item('phone', 'abcdef'))
    assert not serializer.is_valid(), serializer.errors
    # It's a bit unfortunate that this currently is a non_field_error, something for later.
    assert 'did not seem to be a phone number' in serializer.errors['non_field_errors'][0]
Exemplo n.º 6
0
def test_phone_item_international_request_not_allowed():
    with translation.override('ar_SD'):
        serializer = UpdateItemSerializer(data=make_update_item('phone', '1234'))
        assert not serializer.is_valid(), serializer.errors
        assert 'is not available at this time' in str(serializer.errors)
Exemplo n.º 7
0
def test_phone_item_international_not_allowed():
    serializer = UpdateItemSerializer(data=make_update_item('phone', '+8501234'))
    assert not serializer.is_valid(), serializer.errors
    assert 'is not available at this time' in str(serializer.errors)