예제 #1
0
async def test_validate_attr_PHONE_None_allow_none():
    attr_val = await validate_attr(
        attr_name='test_validate_attr_PHONE',
        attr_type=ATTR.PHONE(),
        attr_val=None,
        mode='update',
    )
    assert attr_val == None
예제 #2
0
async def test_validate_attr_PHONE_None():
    with pytest.raises(InvalidAttrException):
        await validate_attr(
            attr_name='test_validate_attr_PHONE',
            attr_type=ATTR.PHONE(),
            attr_val=None,
            mode='create',
        )
예제 #3
0
async def test_validate_attr_PHONE_codes_phone():
    attr_val = await validate_attr(
        attr_name='test_validate_attr_PHONE',
        attr_type=ATTR.PHONE(codes=['971', '1']),
        attr_val='+9710',
        mode='create',
    )
    assert attr_val == '+9710'
예제 #4
0
async def test_validate_attr_PHONE_codes_phone_invalid():
    with pytest.raises(InvalidAttrException):
        await validate_attr(
            attr_name='test_validate_attr_PHONE',
            attr_type=ATTR.PHONE(codes=['971', '1']),
            attr_val='+0',
            mode='create',
        )
예제 #5
0
async def test_validate_attr_PHONE_phone():
    attr_val = await validate_attr(
        attr_name='test_validate_attr_PHONE',
        attr_type=ATTR.PHONE(),
        attr_val='+0',
        mode='create',
    )
    assert attr_val == '+0'
예제 #6
0
async def test_validate_attr_PHONE_default_int():
    attr_type = ATTR.PHONE()
    attr_type._default = 'test_validate_attr_PHONE'
    attr_val = await validate_attr(
        attr_name='test_validate_attr_PHONE',
        attr_type=attr_type,
        attr_val=1,
        mode='create',
    )
    assert attr_val == 'test_validate_attr_PHONE'
예제 #7
0
def test_generate_attr_PHONE_codes():
    attr_val = utils.generate_attr(attr_type=ATTR.PHONE(
        codes=['123', '45', '6']))
    assert re.match(r'^\+(123|45|6)[0-9]+$', attr_val) != None
예제 #8
0
def test_generate_attr_PHONE_no_args():
    attr_val = utils.generate_attr(attr_type=ATTR.PHONE())
    assert re.match(r'^\+[0-9]+$', attr_val) != None