async def test_validate_attr_BOOL_None(): with pytest.raises(InvalidAttrException): await validate_attr( attr_name='test_validate_attr_BOOL', attr_type=ATTR.BOOL(), attr_val=None, mode='create', )
async def test_validate_attr_BOOL_bool(): attr_val = await validate_attr( attr_name='test_validate_attr_BOOL', attr_type=ATTR.BOOL(), attr_val=False, mode='create', ) assert attr_val == False
async def test_validate_attr_BOOL_None_allow_none(): attr_val = await validate_attr( attr_name='test_validate_attr_BOOL', attr_type=ATTR.BOOL(), attr_val=None, mode='update', ) assert attr_val == None
async def test_validate_attr_BOOL_default_None(): attr_type = ATTR.BOOL() attr_type._default = 'test_validate_attr_BOOL' attr_val = await validate_attr( attr_name='test_validate_attr_BOOL', attr_type=attr_type, attr_val=None, mode='create', ) assert attr_val == 'test_validate_attr_BOOL'
def test_generate_attr_BOOL(): attr_val = utils.generate_attr(attr_type=ATTR.BOOL()) assert attr_val in [True, False]