def test_umount(self): """ Attempt to unmount a device by specifying the directory it is mounted on """ mock = MagicMock(return_value={}) with patch.object(mount, "active", mock): self.assertEqual( mount.umount("name"), "name does not have anything mounted" ) mock = MagicMock(return_value={"name": "name"}) with patch.object(mount, "active", mock): mock = MagicMock(return_value={"retcode": True, "stderr": True}) with patch.dict(mount.__salt__, {"cmd.run_all": mock}): self.assertTrue(mount.umount("name")) mock = MagicMock(return_value={"retcode": False}) with patch.dict(mount.__salt__, {"cmd.run_all": mock}): self.assertTrue(mount.umount("name")) # Test unmounting with guestfs util mock = MagicMock() with patch.dict(mount.__salt__, {"guestfs.umount": mock}): mount.umount("/mountpoint", device="/path/to/my.qcow", util="guestfs") mock.assert_called_once_with("/mountpoint", disk="/path/to/my.qcow")
def test_umount(self): """ Attempt to unmount a device by specifying the directory it is mounted on """ mock = MagicMock(return_value={}) with patch.object(mount, "active", mock): self.assertEqual(mount.umount("name"), "name does not have anything mounted") mock = MagicMock(return_value={"name": "name"}) with patch.object(mount, "active", mock): mock = MagicMock(return_value={"retcode": True, "stderr": True}) with patch.dict(mount.__salt__, {"cmd.run_all": mock}): self.assertTrue(mount.umount("name")) mock = MagicMock(return_value={"retcode": False}) with patch.dict(mount.__salt__, {"cmd.run_all": mock}): self.assertTrue(mount.umount("name"))
def test_umount(self): ''' Attempt to unmount a device by specifying the directory it is mounted on ''' mock = MagicMock(return_value={}) with patch.object(mount, 'active', mock): self.assertEqual(mount.umount('name'), 'name does not have anything mounted') mock = MagicMock(return_value={'name': 'name'}) with patch.object(mount, 'active', mock): mock = MagicMock(return_value={'retcode': True, 'stderr': True}) with patch.dict(mount.__salt__, {'cmd.run_all': mock}): self.assertTrue(mount.umount('name')) mock = MagicMock(return_value={'retcode': False}) with patch.dict(mount.__salt__, {'cmd.run_all': mock}): self.assertTrue(mount.umount('name'))
def test_umount(self): ''' Attempt to unmount a device by specifying the directory it is mounted on ''' mock = MagicMock(return_value={}) with patch.object(mount, 'active', mock): self.assertEqual(mount.umount('name'), 'name does not have anything mounted') mock = MagicMock(return_value={'name': 'name'}) with patch.object(mount, 'active', mock): mock = MagicMock(return_value={'retcode': True, 'stderr': True}) with patch.dict(mount.__salt__, {'cmd.run_all': mock}): self.assertTrue(mount.umount('name')) mock = MagicMock(return_value={'retcode': False}) with patch.dict(mount.__salt__, {'cmd.run_all': mock}): self.assertTrue(mount.umount('name'))
def test_umount(self): """ Attempt to unmount a device by specifying the directory it is mounted on """ mock = MagicMock(return_value={}) with patch.object(mount, "active", mock): self.assertEqual(mount.umount("name"), "name does not have anything mounted") mock = MagicMock(return_value={"name": "name"}) with patch.object(mount, "active", mock): mock = MagicMock(return_value={"retcode": True, "stderr": True}) with patch.dict(mount.__salt__, {"cmd.run_all": mock}): self.assertTrue(mount.umount("name")) mock = MagicMock(return_value={"retcode": False}) with patch.dict(mount.__salt__, {"cmd.run_all": mock}): self.assertTrue(mount.umount("name"))