예제 #1
0
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',
		)
예제 #2
0
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
예제 #3
0
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
예제 #4
0
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'
예제 #5
0
def test_generate_attr_BOOL():
    attr_val = utils.generate_attr(attr_type=ATTR.BOOL())
    assert attr_val in [True, False]