Improve hdparm error handling - 2

This commit is contained in:
desbma
2017-02-24 22:09:12 +01:00
parent 6e13ecd613
commit 820034f711
2 changed files with 0 additions and 5 deletions
-1
View File
@@ -97,7 +97,6 @@ class Drive:
try:
output = subprocess.check_output(cmd,
stdin=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
universal_newlines=True)
except subprocess.CalledProcessError:
supported = False
-4
View File
@@ -66,28 +66,24 @@ class TestDrive(unittest.TestCase):
self.assertEqual(self.drive.supportsHitachiTempQuery(), True)
subprocess_check_output_mock.assert_called_once_with(("hdparm", "-H", "/dev/sdz"),
stdin=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
universal_newlines=True)
with unittest.mock.patch("hddfancontrol.subprocess.check_output") as subprocess_check_output_mock:
subprocess_check_output_mock.return_value = "\n/dev/sdz:\nSG_IO: questionable sense data, results may be incorrect\n drive temperature (celsius) is: -18\n drive temperature in range: yes"
self.assertEqual(self.drive.supportsHitachiTempQuery(), False)
subprocess_check_output_mock.assert_called_once_with(("hdparm", "-H", "/dev/sdz"),
stdin=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
universal_newlines=True)
with unittest.mock.patch("hddfancontrol.subprocess.check_output") as subprocess_check_output_mock:
subprocess_check_output_mock.return_value = "\n/dev/sdz:\nSG_IO: missing sense data, results may be incorrect\n drive temperature (celsius) is: -18\n drive temperature in range: yes"
self.assertEqual(self.drive.supportsHitachiTempQuery(), False)
subprocess_check_output_mock.assert_called_once_with(("hdparm", "-H", "/dev/sdz"),
stdin=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
universal_newlines=True)
with unittest.mock.patch("hddfancontrol.subprocess.check_output") as subprocess_check_output_mock:
subprocess_check_output_mock.return_value = "\n/dev/sdz:\nSG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 04 51 40 00 21 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n drive temperature (celsius) is: -18\n drive temperature in range: yes"
self.assertEqual(self.drive.supportsHitachiTempQuery(), False)
subprocess_check_output_mock.assert_called_once_with(("hdparm", "-H", "/dev/sdz"),
stdin=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
universal_newlines=True)
def test_getState(self):