]>
Commit | Line | Data |
---|---|---|
d2e6a577 FG |
1 | import pytest |
2 | from ceph_volume import exceptions | |
3 | from ceph_volume.devices.lvm import trigger | |
4 | ||
5 | ||
6 | class TestParseOSDid(object): | |
7 | ||
8 | def test_no_id_found_if_no_digit(self): | |
9 | with pytest.raises(exceptions.SuffixParsingError): | |
10 | trigger.parse_osd_id('asdlj-ljahsdfaslkjhdfa') | |
11 | ||
12 | def test_no_id_found(self): | |
13 | with pytest.raises(exceptions.SuffixParsingError): | |
14 | trigger.parse_osd_id('ljahsdfaslkjhdfa') | |
15 | ||
16 | def test_id_found(self): | |
17 | result = trigger.parse_osd_id('1-ljahsdfaslkjhdfa') | |
18 | assert result == '1' | |
19 | ||
20 | ||
21 | class TestParseOSDUUID(object): | |
22 | ||
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' | |
26 | ||
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' | |
30 | ||
31 | def test_uuid_is_not_found(self): | |
32 | with pytest.raises(exceptions.SuffixParsingError): | |
33 | trigger.parse_osd_uuid('ljahsdfaslkjhdfa') | |
34 | ||
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') | |
38 | ||
181888fb FG |
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' | |
44 | ||
d2e6a577 | 45 |