Пример #1
0
    def test_012_attr_regex(self):
        """Type query with attribute regex match."""
        q = TypeQuery(self.p, attrs="test12(a|b)", attrs_regex=True)

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test12t1", "test12t2", "test12t3",
                              "test12t4", "test12t5", "test12t6"], types)
Пример #2
0
    def test_010_attr_intersect(self):
        """Type query with attribute set intersection."""
        q = TypeQuery(self.p, attrs=["test10a", "test10b"])

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test10t1", "test10t2", "test10t3",
                              "test10t4", "test10t5", "test10t6"], types)
Пример #3
0
    def test_010_attr_intersect(self):
        """Type query with attribute set intersection."""
        q = TypeQuery(self.p, attrs=["test10a", "test10b"])

        types = sorted(str(t) for t in q.results())
        self.assertListEqual([
            "test10t1", "test10t2", "test10t3", "test10t4", "test10t5",
            "test10t6"
        ], types)
Пример #4
0
    def test_000_unset(self):
        """Type query with no criteria."""
        # query with no parameters gets all types.
        alltypes = sorted(self.p.types())

        q = TypeQuery(self.p)
        qtypes = sorted(q.results())

        self.assertListEqual(alltypes, qtypes)
Пример #5
0
    def test_000_unset(self):
        """Type query with no criteria."""
        # query with no parameters gets all types.
        alltypes = sorted(self.p.types())

        q = TypeQuery(self.p)
        qtypes = sorted(q.results())

        self.assertListEqual(alltypes, qtypes)
Пример #6
0
    def test_012_attr_regex(self):
        """Type query with attribute regex match."""
        q = TypeQuery(self.p, attrs="test12(a|b)", attrs_regex=True)

        types = sorted(str(t) for t in q.results())
        self.assertListEqual([
            "test12t1", "test12t2", "test12t3", "test12t4", "test12t5",
            "test12t6"
        ], types)
Пример #7
0
def get_type_names(policy, tname, is_regex, indirect):
    # Looks like we have to match types and attributes separately
    types = set()
    attributes = set()
    if isinstance(tname, str) or isinstance(tname, BaseType) or is_regex:
        tname = [tname]
    for name in tname:
        types.update(
            TypeQuery(policy, name=name, name_regex=is_regex).results())
        attributes.update(
            TypeAttributeQuery(policy, name=name,
                               name_regex=is_regex).results())

    out = set()
    start = types | attributes
    for x in start:
        out.add(str(x))
        if indirect:
            if isinstance(x, Type):
                [out.add(str(y)) for y in x.attributes()]
            else:
                [out.add(str(y)) for y in x.expand()]

    return out
Пример #8
0
    def test_002_name_regex(self):
        """Type query with regex name match."""
        q = TypeQuery(self.p, name="test2(a|b)", name_regex=True)

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test2a", "test2b"], types)
Пример #9
0
    def test_001_name_exact(self):
        """Type query with exact name match."""
        q = TypeQuery(self.p, name="test1")

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test1"], types)
Пример #10
0
    def test_030_permissive(self):
        """Type query with permissive match"""
        q = TypeQuery(self.p, permissive=True)

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test30"], types)
Пример #11
0
    def test_020_alias_exact(self):
        """Type query with exact alias match."""
        q = TypeQuery(self.p, alias="test20a")

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test20t1"], types)
Пример #12
0
    def test_011_attr_equality(self):
        """Type query with attribute set equality."""
        q = TypeQuery(self.p, attrs=["test11a", "test11b"], attrs_equal=True)

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test11t2"], types)
Пример #13
0
    def test_002_name_regex(self):
        """Type query with regex name match."""
        q = TypeQuery(self.p, name="test2(a|b)", name_regex=True)

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test2a", "test2b"], types)
Пример #14
0
    def test_001_name_exact(self):
        """Type query with exact name match."""
        q = TypeQuery(self.p, name="test1")

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test1"], types)
Пример #15
0
    def test_011_attr_equality(self):
        """Type query with attribute set equality."""
        q = TypeQuery(self.p, attrs=["test11a", "test11b"], attrs_equal=True)

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test11t2"], types)
Пример #16
0
    def test_020_alias_exact(self):
        """Type query with exact alias match."""
        q = TypeQuery(self.p, alias="test20a")

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test20t1"], types)
Пример #17
0
    def test_021_alias_regex(self):
        """Type query with regex alias match."""
        q = TypeQuery(self.p, alias="test21(a|b)", alias_regex=True)

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test21t1", "test21t2"], types)
Пример #18
0
    def test_021_alias_regex(self):
        """Type query with regex alias match."""
        q = TypeQuery(self.p, alias="test21(a|b)", alias_regex=True)

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test21t1", "test21t2"], types)
Пример #19
0
    def test_030_permissive(self):
        """Type query with permissive match"""
        q = TypeQuery(self.p, permissive=True)

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test30"], types)
Пример #20
0
 def __init__(self, parent, policy, perm_map):
     super(TypeQueryTab, self).__init__(parent)
     self.log = logging.getLogger(__name__)
     self.policy = policy
     self.query = TypeQuery(policy)
     self.setupUi()
Пример #21
0
    def test_022_alias_dereference(self):
        """Type query with alias dereference."""
        q = TypeQuery(self.p, name="test22alias", alias_deref=True)

        types = sorted(str(t) for t in q.results())
        self.assertListEqual(["test22"], types)