Skip to content

Commit efe4efb

Browse files
Add checks to compensate code coverage
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
1 parent 16ed521 commit efe4efb

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

tests/test_accessor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_file_accessor(fs):
1818

1919
class TestAccessor(unittest.TestCase):
2020
def setUp(self):
21-
"""Provide the refrence content of the repo/.treeinfo file for check_repo_access()"""
21+
"""Provide the reference content of the repo/.treeinfo file for check_repo_access()"""
2222
with open("tests/data/repo/.treeinfo", "rb") as dot_treeinfo:
2323
self.reference_treeinfo = dot_treeinfo.read()
2424

tests/test_logger.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ def test_openLog_mock_stdin():
3131
assert openLog("test.log") is True
3232
os.close(slave_fd)
3333
os.close(master_fd)
34+
open_mock.assert_called_once_with("test.log", "a", **open_utf8)

tests/test_pci.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class TestValid(unittest.TestCase):
3131

3232
def test_null_with_segment(self):
3333

34+
assert PCI.is_valid("0000:00:00.0") is True
3435
c = PCI("0000:00:00.0")
3536

3637
self.assertEqual(c.segment, 0)
@@ -43,6 +44,7 @@ def test_null_with_segment(self):
4344

4445
def test_null_without_segment(self):
4546

47+
assert PCI.is_valid("00:00.0") is True
4648
c = PCI("00:00.0")
4749

4850
self.assertEqual(c.segment, 0)
@@ -54,28 +56,47 @@ def test_null_without_segment(self):
5456

5557
def test_valid(self):
5658

59+
assert PCI.is_valid("8765:43:1f.3") is True
5760
c = PCI("8765:43:1f.3")
5861

5962
self.assertEqual(c.segment, 0x8765)
6063
self.assertEqual(c.bus, 0x43)
6164
self.assertEqual(c.device, 0x1f)
6265
self.assertEqual(c.function, 0x3)
6366

67+
def test_valid_index(self):
68+
69+
assert PCI.is_valid("8765:43:1f.3[0]") is True
70+
assert PCI.is_valid("1234:56:01.7[1]") is True
71+
c = PCI("1234:56:01.7[1]")
72+
73+
self.assertEqual(c.segment, 0x1234)
74+
self.assertEqual(c.bus, 0x56)
75+
self.assertEqual(c.device, 0x01)
76+
self.assertEqual(c.function, 0x7)
77+
self.assertEqual(c.index, 0x1)
78+
6479
def test_equality(self):
6580

6681
self.assertEqual(PCI("0000:00:00.0"), PCI("00:00.0"))
82+
assert PCI("1234:56:01.7[1]") != PCI("1234:56:01.7[2]")
83+
assert PCI("1234:56:01.2") >= PCI("1234:56:01.2")
84+
assert PCI("1234:56:01.1") <= PCI("1234:56:01.2")
85+
assert PCI("1234:56:01.3") > PCI("1234:56:01.2")
86+
assert PCI("1234:56:01.1") < PCI("1234:56:02.2")
6787

6888

6989
if sys.version_info >= (2, 7):
7090
def assert_videoclass_devices(ids, devs): # type: (PCIIds, PCIDevices) -> None
71-
"""Verification function for checking the otuput of PCIDevices.findByClass()"""
91+
"""Verification function for checking the output of PCIDevices.findByClass()"""
7292
video_class = ids.lookupClass('Display controller')
7393
assert video_class == ["03"]
7494
sorted_devices = sorted(devs.findByClass(video_class),
7595
key=lambda x: x['id'])
7696

7797
# Assert devs.findByClass() finding 3 GPUs from tests/data/lspci-mn in our mocked PCIIds DB:
7898
assert len(sorted_devices) == 3
99+
assert len(devs.findByClass("03", "80")) == 2
79100

80101
# For each of the found devices, assert these expected values:
81102
for (video_dev,

0 commit comments

Comments
 (0)