Esempio n. 1
0
 def test_resolve(self):
     self.assertEqual(
         ResolveLink(None, None),
         self.specification.resolve_device(),
     )
     self.assertEqual(
         ResolveLink("mount", "relative_path"),
         self.specification.resolve_path(),
     )
Esempio n. 2
0
 def test_resolve(self):
     self.assertEqual(
         ResolveLink("lvm_volume_group", "name"),
         self.specification.resolve_device(),
     )
     self.assertEqual(
         ResolveLink(None, None),
         self.specification.resolve_path(),
     )
Esempio n. 3
0
 def test_resolve(self):
     self.assertEqual(
         ResolveLink("device", None),
         self.specification.resolve_device(),
     )
     self.assertEqual(
         ResolveLink("mountpoint", None),
         self.specification.resolve_path(),
     )
Esempio n. 4
0
 def test_resolve(self):
     self.assertEqual(
         ResolveLink("partition_table", "1"),
         self.specification.resolve_device(),
     )
     self.assertEqual(
         ResolveLink(None, None),
         self.specification.resolve_path(),
     )
Esempio n. 5
0
 def test_resolve(self):
     self.assertEqual(
         ResolveLink(None, "/dev/name"),
         self.specification.resolve_device(),
     )
     self.assertEqual(
         ResolveLink(None, None),
         self.specification.resolve_path(),
     )
Esempio n. 6
0
    def test_successful_recursive_resolve(self):
        for msg, node_factory, graph_resolve in GraphResolveTest.parameterization:
            with self.subTest(msg=msg):
                a = node_factory("a", ["b"], resolve=ResolveLink("b", "y"))
                b = node_factory("b", [], resolve=ResolveLink(None, "x"))

                nodes = [a, b]
                graph = Graph(nodes)

                self.assertEqual("x/y", graph_resolve(graph, "a"))
Esempio n. 7
0
    def test_undeclared_recursive_resolve(self):
        for msg, node_factory, graph_resolve in GraphResolveTest.parameterization:
            with self.subTest(msg=msg):
                a = node_factory("a", [], resolve=ResolveLink("b", "y"))
                b = node_factory("b", [], resolve=ResolveLink(None, "x"))

                nodes = [a, b]
                graph = Graph(nodes)

                with self.assertRaises(GraphResolveError) as context:
                    graph_resolve(graph, "a")

                self.assertEqual("b", context.exception.reference)
Esempio n. 8
0
 def __init__(
         self,
         name: str,
         dependencies: List[str],
         references: List[str] = None,
         resolve_device: ResolveLink = ResolveLink(None, None),
         resolve_path: ResolveLink = ResolveLink(None, None),
 ):
     if references is None:
         references = []
     super().__init__(name, dependencies, references)
     self._resolve_device = resolve_device
     self._resolve_path = resolve_path
Esempio n. 9
0
 def fn(
         name: str,
         dependencies: List[str],
         references: List[str] = None,
         resolve: ResolveLink = ResolveLink(None, None),
 ) -> TestGraphNode:
     if references is None:
         references = []
     return TestGraphNode(name,
                          dependencies,
                          references=references,
                          resolve_path=resolve)
Esempio n. 10
0
 def resolve_path(self) -> ResolveLink:
     return ResolveLink(self.mountpoint, None)
Esempio n. 11
0
 def resolve_path(self) -> ResolveLink:
     return ResolveLink(None, self.name)
Esempio n. 12
0
 def resolve_device(self) -> ResolveLink:
     return ResolveLink(None, self.name)
Esempio n. 13
0
 def resolve_device(self) -> ResolveLink:
     return ResolveLink(self.device, None)
Esempio n. 14
0
 def resolve_device(self) -> ResolveLink:
     return ResolveLink(None, f"${self.capture}")
Esempio n. 15
0
 def resolve_device(self) -> ResolveLink:
     return ResolveLink(None, f"/dev/{self.name}")
Esempio n. 16
0
 def resolve_path(self) -> ResolveLink:
     return ResolveLink(None, "/", _join)
Esempio n. 17
0
 def resolve_device(self) -> ResolveLink:
     return ResolveLink(self.partition_table, str(self.number))
Esempio n. 18
0
 def resolve_path(self) -> ResolveLink:
     return ResolveLink(self.mount, self.relative_path)
Esempio n. 19
0
 def resolve_path(self) -> ResolveLink:
     return ResolveLink(None, None)
Esempio n. 20
0
 def resolve_device(self) -> ResolveLink:
     return ResolveLink(self.lvm_volume_group, self.name)