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
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', )
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'
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', )
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'
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'
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
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