MCPcopy Create free account
hub / github.com/ceph/ceph / TestDevicesEquality

Class TestDevicesEquality

src/python-common/ceph/tests/test_inventory.py:26–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25
26class TestDevicesEquality():
27 created_time1 = datetime_now()
28 created_time2 = created_time1 + datetime.timedelta(seconds=30)
29
30 @pytest.mark.parametrize(
31 "old_devices, new_devices, expected_equal",
32 [
33 ( # identical list should be equal
34 Devices([Device('/dev/sdb', available=True, created=created_time1),
35 Device('/dev/sdc', available=True, created=created_time1)]),
36 Devices([Device('/dev/sdb', available=True, created=created_time1),
37 Device('/dev/sdc', available=True, created=created_time1)]),
38 True,
39 ),
40 ( # differing only in created time should still be equal
41 Devices([Device('/dev/sdb', available=True, created=created_time1),
42 Device('/dev/sdc', available=True, created=created_time1)]),
43 Devices([Device('/dev/sdb', available=True, created=created_time2),
44 Device('/dev/sdc', available=True, created=created_time2)]),
45 True,
46 ),
47 ( # differing in some other field should make them not equal
48 Devices([Device('/dev/sdb', available=True, created=created_time1),
49 Device('/dev/sdc', available=True, created=created_time1)]),
50 Devices([Device('/dev/sdb', available=False, created=created_time1),
51 Device('/dev/sdc', available=True, created=created_time1)]),
52 False,
53 ),
54 ( # different amount of devices should not pass equality
55 Devices([Device('/dev/sdb', available=True, created=created_time1),
56 Device('/dev/sdc', available=True, created=created_time1)]),
57 Devices([Device('/dev/sdb', available=True, created=created_time1),
58 Device('/dev/sdc', available=True, created=created_time1),
59 Device('/dev/sdd', available=True, created=created_time1)]),
60 False,
61 ),
62 ( # differing order should not affect equality
63 Devices([Device('/dev/sdb', available=True, created=created_time1),
64 Device('/dev/sdc', available=True, created=created_time1)]),
65 Devices([Device('/dev/sdc', available=True, created=created_time1),
66 Device('/dev/sdb', available=True, created=created_time1)]),
67 True,
68 ),
69 ])
70 def test_equality(self, old_devices, new_devices, expected_equal):
71 assert (old_devices == new_devices) == expected_equal

Callers

nothing calls this directly

Calls 1

datetime_nowFunction · 0.90

Tested by

no test coverage detected