2 from ceph_volume import exceptions
3 from ceph_volume.devices.simple import trigger
6 class TestParseOSDid(object):
8 def test_no_id_found_if_no_digit(self):
9 with pytest.raises(exceptions.SuffixParsingError):
10 trigger.parse_osd_id('asdlj-ljahsdfaslkjhdfa')
12 def test_no_id_found(self):
13 with pytest.raises(exceptions.SuffixParsingError):
14 trigger.parse_osd_id('ljahsdfaslkjhdfa')
16 def test_id_found(self):
17 result = trigger.parse_osd_id('1-ljahsdfaslkjhdfa')
21 class TestParseOSDUUID(object):
23 def test_uuid_is_parsed(self):
24 result = trigger.parse_osd_uuid('1-asdf-ljkh-asdf-ljkh-asdf')
25 assert result == 'asdf-ljkh-asdf-ljkh-asdf'
27 def test_uuid_is_parsed_longer_sha1(self):
28 result = trigger.parse_osd_uuid('1-foo-bar-asdf-ljkh-asdf-ljkh-asdf')
29 assert result == 'foo-bar-asdf-ljkh-asdf-ljkh-asdf'
31 def test_uuid_is_not_found(self):
32 with pytest.raises(exceptions.SuffixParsingError):
33 trigger.parse_osd_uuid('ljahsdfaslkjhdfa')
35 def test_uuid_is_not_found_missing_id(self):
36 with pytest.raises(exceptions.SuffixParsingError):
37 trigger.parse_osd_uuid('ljahs-dfa-slkjhdfa-foo')
39 def test_robust_double_id_in_uuid(self):
40 # it is possible to have the id in the SHA1, this should
41 # be fine parsing that
42 result = trigger.parse_osd_uuid("1-abc959fd-1ec9-4864-b141-3154f9b9f8ed")
43 assert result == 'abc959fd-1ec9-4864-b141-3154f9b9f8ed'