Skip to content

Commit

Permalink
Fixes tests of smartctl plugins
Browse files Browse the repository at this point in the history
The function `_list_disks` is now `_list_devices`.

Signed-off-by: Guillaume <[email protected]>
  • Loading branch information
gthvn1 committed Jan 27, 2025
1 parent 3473dc8 commit 400c6d7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/test_smartctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,25 @@
}"""

@mock.patch("smartctl.run_command", autospec=True)
@mock.patch("smartctl._list_disks", autospec=True)
@mock.patch("smartctl._list_devices", autospec=True)
class TestSmartctl:
def test_smartctl_error(self, _list_disks, run_command, fs):
_list_disks.side_effect = Exception("Error!")
def test_smartctl_error(self, _list_devices, run_command, fs):
_list_devices.side_effect = Exception("Error!")

with pytest.raises(XenAPIPlugin.Failure) as e:
get_health(None, None)
assert e.value.params[0] == '-1'
assert e.value.params[1] == 'Error!'

def test_smartctl_information(self, _list_disks, run_command, fs):
_list_disks.return_value = ["/dev/sda"]
def test_smartctl_information(self, _list_devices, run_command, fs):
_list_devices.return_value = ["/dev/sda"]
run_command.return_value = {"stdout": SMARTCTL_INFO}

res = get_information(None, None)
assert json.loads(res) == json.loads(SMARTCTL_INFO_EXPECTED)

def test_smartctl_health(self, _list_disks, run_command, fs):
_list_disks.return_value = ["/dev/sda"]
def test_smartctl_health(self, _list_devices, run_command, fs):
_list_devices.return_value = ["/dev/sda"]
run_command.return_value = {"stdout": SMARTCTL_HEALTH}

res = get_health(None, None)
Expand Down

0 comments on commit 400c6d7

Please sign in to comment.