def test_resolve(self): self.assertEqual( ResolveLink(None, None), self.specification.resolve_device(), ) self.assertEqual( ResolveLink("mount", "relative_path"), self.specification.resolve_path(), )
def test_resolve(self): self.assertEqual( ResolveLink("lvm_volume_group", "name"), self.specification.resolve_device(), ) self.assertEqual( ResolveLink(None, None), self.specification.resolve_path(), )
def test_resolve(self): self.assertEqual( ResolveLink("device", None), self.specification.resolve_device(), ) self.assertEqual( ResolveLink("mountpoint", None), self.specification.resolve_path(), )
def test_resolve(self): self.assertEqual( ResolveLink("partition_table", "1"), self.specification.resolve_device(), ) self.assertEqual( ResolveLink(None, None), self.specification.resolve_path(), )
def test_resolve(self): self.assertEqual( ResolveLink(None, "/dev/name"), self.specification.resolve_device(), ) self.assertEqual( ResolveLink(None, None), self.specification.resolve_path(), )
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"))
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)
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
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)
def resolve_path(self) -> ResolveLink: return ResolveLink(self.mountpoint, None)
def resolve_path(self) -> ResolveLink: return ResolveLink(None, self.name)
def resolve_device(self) -> ResolveLink: return ResolveLink(None, self.name)
def resolve_device(self) -> ResolveLink: return ResolveLink(self.device, None)
def resolve_device(self) -> ResolveLink: return ResolveLink(None, f"${self.capture}")
def resolve_device(self) -> ResolveLink: return ResolveLink(None, f"/dev/{self.name}")
def resolve_path(self) -> ResolveLink: return ResolveLink(None, "/", _join)
def resolve_device(self) -> ResolveLink: return ResolveLink(self.partition_table, str(self.number))
def resolve_path(self) -> ResolveLink: return ResolveLink(self.mount, self.relative_path)
def resolve_path(self) -> ResolveLink: return ResolveLink(None, None)
def resolve_device(self) -> ResolveLink: return ResolveLink(self.lvm_volume_group, self.name)