mirror of https://github.com/home-assistant/core
28 lines
905 B
Python
28 lines
905 B
Python
"""Tests for permissions merging."""
|
|
|
|
from homeassistant.auth.permissions.merge import merge_policies
|
|
|
|
|
|
def test_merging_permissions_true_rules_dict() -> None:
|
|
"""Test merging policy with two entities."""
|
|
policy1 = {
|
|
"something_else": True,
|
|
"entities": {"entity_ids": {"light.kitchen": True}},
|
|
}
|
|
policy2 = {"entities": {"entity_ids": True}}
|
|
assert merge_policies([policy1, policy2]) == {
|
|
"something_else": True,
|
|
"entities": {"entity_ids": True},
|
|
}
|
|
|
|
|
|
def test_merging_permissions_multiple_subcategories() -> None:
|
|
"""Test merging policy with two entities."""
|
|
policy1 = {"entities": None}
|
|
policy2 = {"entities": {"entity_ids": True}}
|
|
policy3 = {"entities": True}
|
|
assert merge_policies([policy1, policy2]) == policy2
|
|
assert merge_policies([policy1, policy3]) == policy3
|
|
|
|
assert merge_policies([policy2, policy3]) == policy3
|