Beispiel #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'
Beispiel #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
Beispiel #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 == '*****@*****.**'
Beispiel #4
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'
Beispiel #5
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 == '*****@*****.**'
Beispiel #6
0
def test_invalid_item(invalid):
    serializer = UpdateItemSerializer(data=invalid)
    assert not serializer.is_valid()
Beispiel #7
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]
Beispiel #8
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)
Beispiel #9
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)