Skip to content

Commit

Permalink
Fixed: Missing coverage restored.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersulyok committed Jan 1, 2024
1 parent 3573fb6 commit f782756
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/test_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ def mocked_open(path: str, *args, **kwargs):
patch('os.path.exists', mock_exists), \
patch('builtins.open', mock_open):
d = Disk(disk_name)
os.system("echo 'something' > " + my_td.disks[0].hwmon_path)
with self.assertRaises(Exception) as cm:
d.get_temperature()
self.assertEqual(type(cm.exception), ValueError, error)
d._Disk__hwmon_path = None
with self.assertRaises(Exception) as cm:
d.get_temperature()
Expand All @@ -377,14 +381,14 @@ def test_get_temperature(self):

# Test valid functionality.
for i in range(20):
self.pt_gt_p1("nvme0n1", DiskType.NVME, "get_temperature 1")
self.pt_gt_p1("sda", DiskType.SSD, "get_temperature 2")
self.pt_gt_p1("sdb", DiskType.HDD, "get_temperature 3")

# Test assertion.
self.pt_gt_n1("nvme0n1", DiskType.NVME, "get_temperature 4")
self.pt_gt_n1("sda", DiskType.SSD, "get_temperature 5")
self.pt_gt_n1("sdb", DiskType.HDD, "get_temperature 6")
self.pt_gt_p1("nvme0n1", DiskType.NVME, f"get_temperature {i}")
self.pt_gt_p1("sda", DiskType.SSD, "get_temperature 21")
self.pt_gt_p1("sdb", DiskType.HDD, "get_temperature 22")

# Test Runtime assertion.
self.pt_gt_n1("nvme0n1", DiskType.NVME, "get_temperature 23")
self.pt_gt_n1("sda", DiskType.SSD, "get_temperature 24")
self.pt_gt_n1("sdb", DiskType.HDD, "get_temperature 25")

def pt_gsd_p1(self, disk: Disk, nocheck: bool, sudo: str, smartctrl_path: str, error: str) -> None:
"""Primitive positive test function. It contains the following steps:
Expand Down

0 comments on commit f782756

Please sign in to comment.