Exemplo n.º 1
0
    def test_resolve_2(self):
        index = indexer.crawl(indexer.build(self.rels2))

        self.assertEqual(indexer.resolve(index), {
            'a': {
                'b': (
                    ('a', 'b'),
                ),
                'c': (
                    ('a', 'c'),
                ),
            },
            'b': {
                'a': (
                    ('b', 'a'),
                ),
                'c': (
                    ('b', 'a'),
                    ('a', 'c'),
                ),
            },
            'c': {
                'a': (
                    ('c', 'a'),
                ),
                'b': (
                    ('c', 'a'),
                    ('a', 'b'),
                )
            },
        })
Exemplo n.º 2
0
    def test_crawl_2(self):
        index = indexer.build(self.rels2)

        self.assertEqual(
            indexer.crawl(index),
            {"a": {"b": ("a", "b"), "c": ("a", "c")}, "b": {"a": "a", "c": "a"}, "c": {"a": "a", "b": "a"}},
        )
Exemplo n.º 3
0
    def test_resolve_path(self):
        index = indexer.crawl(indexer.build(self.rels1))

        self.assertEqual(indexer._resolve_path(index, 'a', 'a'), None)
        self.assertEqual(indexer._resolve_path(index, 'a', 'b'), [
            ('a', 'b'),
        ])
        self.assertEqual(indexer._resolve_path(index, 'a', 'c'), [
            ('a', 'b'),
            ('b', 'c'),
        ])

        self.assertEqual(indexer._resolve_path(index, 'b', 'b'), None)
        self.assertEqual(indexer._resolve_path(index, 'b', 'a'), [
            ('b', 'a'),
        ])
        self.assertEqual(indexer._resolve_path(index, 'b', 'c'), [
            ('b', 'c'),
        ])

        self.assertEqual(indexer._resolve_path(index, 'c', 'c'), None)
        self.assertEqual(indexer._resolve_path(index, 'c', 'b'), [
            ('c', 'b'),
        ])
        self.assertEqual(indexer._resolve_path(index, 'c', 'a'), [
            ('c', 'b'),
            ('b', 'a'),
        ])
Exemplo n.º 4
0
    def test_crawl_3(self):
        index = indexer.build(self.rels3)

        self.assertEqual(indexer.crawl(index), {
            'a': {
                'b': ('a', 'b', {}),
            },
            'b': {
                'a': 'a',
            }
        })
Exemplo n.º 5
0
    def test_resolve_1(self):
        index = indexer.crawl(indexer.build(self.rels1))

        self.assertEqual(
            indexer.resolve(index),
            {
                "a": {"b": (("a", "b"),), "c": (("a", "b"), ("b", "c"))},
                "b": {"a": (("b", "a"),), "c": (("b", "c"),)},
                "c": {"b": (("c", "b"),), "a": (("c", "b"), ("b", "a"))},
            },
        )
Exemplo n.º 6
0
    def test_resolve_path(self):
        index = indexer.crawl(indexer.build(self.rels1))

        self.assertEqual(indexer._resolve_path(index, "a", "a"), None)
        self.assertEqual(indexer._resolve_path(index, "a", "b"), [("a", "b")])
        self.assertEqual(indexer._resolve_path(index, "a", "c"), [("a", "b"), ("b", "c")])

        self.assertEqual(indexer._resolve_path(index, "b", "b"), None)
        self.assertEqual(indexer._resolve_path(index, "b", "a"), [("b", "a")])
        self.assertEqual(indexer._resolve_path(index, "b", "c"), [("b", "c")])

        self.assertEqual(indexer._resolve_path(index, "c", "c"), None)
        self.assertEqual(indexer._resolve_path(index, "c", "b"), [("c", "b")])
        self.assertEqual(indexer._resolve_path(index, "c", "a"), [("c", "b"), ("b", "a")])
Exemplo n.º 7
0
    def test_resolve_3(self):
        index = indexer.crawl(indexer.build(self.rels3))

        self.assertEqual(indexer.resolve(index), {
            'a': {
                'b': (
                    ('a', 'b', {}),
                ),
            },
            'b': {
                'a': (
                    ('b', 'a', {}),
                ),
            }
        })
Exemplo n.º 8
0
    def test_crawl_1(self):
        index = indexer.build(self.rels1)

        self.assertEqual(indexer.crawl(index), {
            'a': {
                'b': ('a', 'b'),
                'c': 'b',
            },
            'b': {
                'a': 'a',
                'c': ('b', 'c'),
            },
            'c': {
                'b': 'b',
                'a': 'b',
            },
        })
Exemplo n.º 9
0
 def test_none(self):
     self.assertEqual(indexer.crawl({}), {})
Exemplo n.º 10
0
    def test_crawl_3(self):
        index = indexer.build(self.rels3)

        self.assertEqual(indexer.crawl(index), {"a": {"b": ("a", "b", {})}, "b": {"a": "a"}})
Exemplo n.º 11
0
    def test_resolve_3(self):
        index = indexer.crawl(indexer.build(self.rels3))

        self.assertEqual(indexer.resolve(index), {"a": {"b": (("a", "b", {}),)}, "b": {"a": (("b", "a", {}),)}})