def test_expand_partitions(self): def normal(name): return Container(name, 'id-' + name, ContainerStatus.UP) containers = [normal(name) for name in ["c1", "c2", "c3", "c4", "c5"]] # add a holy container as well containers.append( Container('c6', 'id-c6', ContainerStatus.UP, holy=True)) partitions = expand_partitions(containers, [["c1", "c3"]]) self.assert_partitions(partitions, [["c1", "c3"], ["c2", "c4", "c5"]]) partitions = expand_partitions(containers, [["c1", "c3"], ["c4"]]) self.assert_partitions(partitions, [["c1", "c3"], ["c2", "c5"], ["c4"]]) with self.assertRaisesRegexp(BlockadeError, "unknown"): expand_partitions(containers, [["c1"], ["c100"]]) with self.assertRaisesRegexp(BlockadeError, "holy"): expand_partitions(containers, [["c1"], ["c2", "c6"]])
def normal(name): return Container(name, 'id-' + name, ContainerStatus.UP)