示例#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(),
     )
示例#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(),
     )
示例#3
0
 def test_resolve(self):
     self.assertEqual(
         ResolveLink("device", None),
         self.specification.resolve_device(),
     )
     self.assertEqual(
         ResolveLink("mountpoint", None),
         self.specification.resolve_path(),
     )
示例#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(),
     )
示例#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(),
     )
示例#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"))
示例#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)
示例#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
示例#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)
示例#10
0
 def resolve_path(self) -> ResolveLink:
     return ResolveLink(self.mountpoint, None)
示例#11
0
 def resolve_path(self) -> ResolveLink:
     return ResolveLink(None, self.name)
示例#12
0
 def resolve_device(self) -> ResolveLink:
     return ResolveLink(None, self.name)
示例#13
0
 def resolve_device(self) -> ResolveLink:
     return ResolveLink(self.device, None)
示例#14
0
 def resolve_device(self) -> ResolveLink:
     return ResolveLink(None, f"${self.capture}")
示例#15
0
 def resolve_device(self) -> ResolveLink:
     return ResolveLink(None, f"/dev/{self.name}")
示例#16
0
 def resolve_path(self) -> ResolveLink:
     return ResolveLink(None, "/", _join)
示例#17
0
 def resolve_device(self) -> ResolveLink:
     return ResolveLink(self.partition_table, str(self.number))
示例#18
0
 def resolve_path(self) -> ResolveLink:
     return ResolveLink(self.mount, self.relative_path)
示例#19
0
 def resolve_path(self) -> ResolveLink:
     return ResolveLink(None, None)
示例#20
0
 def resolve_device(self) -> ResolveLink:
     return ResolveLink(self.lvm_volume_group, self.name)