def test_entities_entity_ids_entity_id_true(): """Test entity ID policy.""" policy = {'entity_ids': {'light.kitchen': True}} permissions.ENTITY_POLICY_SCHEMA(policy) compiled = permissions._compile_entities(policy) assert compiled('light.kitchen', []) is True assert compiled('switch.kitchen', []) is False
def test_entities_entity_ids_entity_id_false(): """Test entity ID policy.""" policy = {'entity_ids': {'light.kitchen': False}} with pytest.raises(vol.Invalid): permissions.ENTITY_POLICY_SCHEMA(policy)
def test_entities_domains_domain_false(): """Test entity ID policy.""" policy = {'domains': {'light': False}} with pytest.raises(vol.Invalid): permissions.ENTITY_POLICY_SCHEMA(policy)
def test_entities_domains_true(): """Test entity ID policy.""" policy = {'domains': True} permissions.ENTITY_POLICY_SCHEMA(policy) compiled = permissions._compile_entities(policy) assert compiled('light.kitchen', []) is True
def test_entities_false(): """Test entity ID policy.""" policy = False with pytest.raises(vol.Invalid): permissions.ENTITY_POLICY_SCHEMA(policy)
def test_entities_empty(): """Test entity ID policy.""" policy = {} permissions.ENTITY_POLICY_SCHEMA(policy) compiled = permissions._compile_entities(policy) assert compiled('light.kitchen', []) is False