예제 #1
0
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
예제 #2
0
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)
예제 #3
0
def test_entities_domains_domain_false():
    """Test entity ID policy."""
    policy = {'domains': {'light': False}}
    with pytest.raises(vol.Invalid):
        permissions.ENTITY_POLICY_SCHEMA(policy)
예제 #4
0
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
예제 #5
0
def test_entities_false():
    """Test entity ID policy."""
    policy = False
    with pytest.raises(vol.Invalid):
        permissions.ENTITY_POLICY_SCHEMA(policy)
예제 #6
0
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