예제 #1
0
    def test_find_flat_nodes(self):
        subtree = config.E.target(
            config.E.path(
                location="A",
                state="evicted"
            ),
            config.E.path(
                location="A/B/C",
                state="included"
            ),
            config.E.path(
                location="A/B/C/D",
                state="evicted"
            ),
            config.E.path(
                location="A/E",
                state="included"
            )
        )

        self.assertSequenceEqual(
            list(config.extract_flat_nodes(subtree)),
            [
                (target.State.EVICTED, "A"),
                (target.State.INCLUDED, "A/B/C"),
                (target.State.EVICTED, "A/B/C/D"),
                (target.State.INCLUDED, "A/E"),
            ]
        )
예제 #2
0
    def test_embed_flat_nodes(self):
        flat_nodes = [
            (target.State.EVICTED, "A"),
            (target.State.INCLUDED, "A/B/C"),
            (target.State.EVICTED, "A/B/C/D"),
            (target.State.INCLUDED, "A/E"),
        ]

        subtree = config.E.target()

        config.embed_flat_nodes(
            subtree,
            flat_nodes
        )

        self.assertSequenceEqual(
            list(config.extract_flat_nodes(subtree)),
            flat_nodes
        )