Beispiel #1
0
 def filter_host_tags(
     self,
     hosts: Iterable[BIHostData],
     tag_conditions: TaggroupIDToTagCondition,
 ) -> Iterable[BIHostData]:
     return (
         host for host in hosts  #
         if all(
             matches_tag_condition(
                 taggroup_id,
                 tag_condition,
                 host.tags,
             ) for taggroup_id, tag_condition in tag_conditions.items()))
Beispiel #2
0
def test_matches_tag_condition(
    taggroud_id: TaggroupID,
    tag_condition: TagCondition,
    expected_result: bool,
) -> None:
    assert (matches_tag_condition(
        taggroud_id,
        tag_condition,
        {
            ("t1", "abc"),
            ("t2", "xyz"),
            ("t3", "123"),
            ("t4", "456"),
        },
    ) is expected_result)