def test_duplicate_parent(self): with self.assertRaises(DuplicateParentError): _build_volume_chain( [(_BLANK_UUID, 'a'), ('a', 'b'), ('a', 'c')])
def test_loop(self): with self.assertRaises(ChainLoopError): _build_volume_chain([ (_BLANK_UUID, 'a'), ('a', 'b'), ('b', 'c'), ('c', 'a')])
def test_no_base_volume(self): with self.assertRaises(NoBaseVolume): _build_volume_chain([('a', 'b'), ('b', 'c')])
def test_orphan_volumes(self): volumes_children = [(_BLANK_UUID, 'a'), ('a', 'b'), ('c', 'd')] with self.assertRaises(OrphanVolumes) as cm: _build_volume_chain(volumes_children) self.assertEqual(cm.exception.volumes_children, volumes_children)
def test_simple_chain(self): volumes_children = [(_BLANK_UUID, 'a'), ('a', 'b'), ('b', 'c')] self.assertEqual(_build_volume_chain( volumes_children), ['a', 'b', 'c'])
def test_empty(self): self.assertEqual(_build_volume_chain([]), [])
def test_only_base_volume(self): self.assertEqual(_build_volume_chain([(_BLANK_UUID, 'a')]), ['a'])
def test_no_base_volume(): with pytest.raises(NoBaseVolume): _build_volume_chain([('a', 'b'), ('b', 'c')])
def test_duplicate_parent(): with pytest.raises(DuplicateParentError): _build_volume_chain( [(_BLANK_UUID, 'a'), ('a', 'b'), ('a', 'c')])
def test_loop(): with pytest.raises(ChainLoopError): _build_volume_chain([ (_BLANK_UUID, 'a'), ('a', 'b'), ('b', 'c'), ('c', 'a')])
def test_simple_chain(): volumes_children = [(_BLANK_UUID, 'a'), ('a', 'b'), ('b', 'c')] assert _build_volume_chain(volumes_children) == ['a', 'b', 'c']
def test_orphan_volumes(): volumes_children = [(_BLANK_UUID, 'a'), ('a', 'b'), ('c', 'd')] with pytest.raises(OrphanVolumes) as cm: _build_volume_chain(volumes_children) assert cm.value.volumes_children == volumes_children
def test_only_base_volume(): assert _build_volume_chain([(_BLANK_UUID, 'a')]) == ['a']
def test_empty(): assert _build_volume_chain([]) == []