Skip to content

Commit

Permalink
Add test case for _get_mounted_devices method
Browse files Browse the repository at this point in the history
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
  • Loading branch information
mihaelabalutoiu authored and Dany9966 committed Sep 16, 2024
1 parent 87d3541 commit 676d6c9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions coriolis/tests/osmorphing/osmount/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,32 @@ def test__get_mounted_devices(self, mock_exec_cmd):

self.assertEqual(result, ['/dev/sda1', '/dev/sda2'])

@mock.patch.object(base.BaseSSHOSMountTools, '_exec_cmd')
@mock.patch.object(base.utils, 'test_ssh_path')
def test__get_mounted_devices_not_found(self, mock_test_ssh_path,
mock_exec_cmd):
mock_exec_cmd.side_effect = [
b"/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro)\n",
b"/dev/sda1",
b""
]
mock_test_ssh_path.return_value = False

with self.assertLogs('coriolis.osmorphing.osmount.base',
level=logging.WARN):
result = self.base_os_mount_tools._get_mounted_devices()
self.assertEqual(result, [])

mock_exec_cmd.assert_has_calls([
mock.call("cat /proc/mounts"),
mock.call("readlink -en /dev/sda1"),
mock.call("ls -al /dev | grep ^b")
])

mock_test_ssh_path.assert_called_once_with(
self.base_os_mount_tools._ssh, "/dev/sda1"
)

@mock.patch.object(base.BaseSSHOSMountTools, '_exec_cmd')
def test__get_mount_destinations(self, mock_exec_cmd):
mock_exec_cmd.return_value = (
Expand Down

0 comments on commit 676d6c9

Please sign in to comment.