def setUp(self): self.configuration = Configuration( shell="shell", dd_bs="dd_bs", random_device="random_device", media_dir="media_dir", tmp_dir="tmp_dir", )
def test_run(self, make_mode, make_action): spec1 = TestSpecification("spec1", [Command(["1"]), Command(["2"])]) spec2 = TestSpecification("spec2", [Command(["3"]), Command(["4"])]) config = Configuration( shell="", dd_bs="", random_device="", media_dir="", tmp_dir="", ) graph = Graph([spec1, spec2]) mode = MagicMock() action = MagicMock() make_mode.return_value = mode make_action.return_value = action run(config, graph, "action", "mode") action.assert_called_once_with(mode, AnyIter([spec1, spec2])) make_action.assert_called_once_with("action", AnyType()) make_mode.assert_called_once_with("mode")
def __init__(self, specification: Specification): super().__init__() configuration = Configuration( shell="shell", dd_bs="dd_bs", random_device="random_device", media_dir="media_dir", tmp_dir="tmp_dir", ) graph = Graph( [ TestSpecification("device"), TestSpecification("file"), TestSpecification("filesystem"), TestSpecification("keyfile"), TestSpecification("lvm_logical_volume"), TestSpecification("lvm_physical_volume"), TestSpecification("lvm_cachedata_volume"), TestSpecification("lvm_cachemeta_volume"), TestSpecification("mountpoint"), TestSpecification("name"), TestSpecification("partition_table"), ] ) self.context = CommandContext(configuration, graph) self.specification = specification
def setUp(self): configuration = Configuration( shell="shell", dd_bs="dd_bs", random_device="random_device", media_dir="media_dir", tmp_dir="tmp_dir", ) graph = Graph([]) self.context = CommandContext(configuration, graph) self.generators = [ TestActionCommandGenerator( "gen_1", apply=TestCommandGenerator([ Command(["apply_1"]), Command(["apply_2"]), ]), post_apply=TestCommandGenerator([ Command(["post_apply_1"]), Command(["post_apply_2"]), ]), up=TestCommandGenerator([ Command(["up_1"]), Command(["up_2"]), ]), pre_down=TestCommandGenerator([ Command(["pre_down_1"]), Command(["pre_down_2"]), ]), down=TestCommandGenerator([ Command(["down_1"]), Command(["down_2"]), ]), ), TestActionCommandGenerator( "gen_2", apply=TestCommandGenerator([ Command(["apply_3"]), Command(["apply_4"]), ]), post_apply=TestCommandGenerator([ Command(["post_apply_3"]), Command(["post_apply_4"]), ]), up=TestCommandGenerator([ Command(["up_3"]), Command(["up_4"]), ]), pre_down=TestCommandGenerator([ Command(["pre_down_3"]), Command(["pre_down_4"]), ]), down=TestCommandGenerator([ Command(["down_3"]), Command(["down_4"]), ]), ), ]
def test_command_context(self): configuration = Configuration( shell="shell", dd_bs="dd_bs", random_device="random_device", media_dir="media_dir", tmp_dir="tmp_dir", ) graph = Graph([]) context = CommandContext(configuration, graph) self.assertEqual(configuration, context.config) self.assertEqual(graph, context.graph)
class ConfigurationTest(unittest.TestCase): def setUp(self): self.configuration = Configuration( shell="shell", dd_bs="dd_bs", random_device="random_device", media_dir="media_dir", tmp_dir="tmp_dir", ) def test_values(self): self.assertEqual("shell", self.configuration.shell) self.assertEqual("dd_bs", self.configuration.dd_bs) self.assertEqual("random_device", self.configuration.random_device) self.assertEqual("media_dir", self.configuration.media_dir) self.assertEqual("tmp_dir", self.configuration.tmp_dir) def test_paths(self): self.assertEqual( "media_dir/path", self.configuration.media_path("path"), ) self.assertEqual("tmp_dir/path", self.configuration.tmp_path("path"))
def load_config(configuration: str) -> Configuration: with open(configuration, "r") as f: return Configuration(**json.load(f))