示例#1
0
 def test_clear(self):
     '''
     Test if it pass in the mnt dict returned from nbd_mount
     to unmount and disconnect the image from nbd.
     '''
     mock_run = MagicMock(return_value=True)
     with patch.dict(qemu_nbd.__salt__,
                     {'cmd.run': mock_run,
                      'mount.umount': MagicMock(side_effect=[False, True])}):
         self.assertDictEqual(qemu_nbd.clear({"/mnt/foo": "/dev/nbd0p1"}),
                              {'/mnt/foo': '/dev/nbd0p1'})
         self.assertDictEqual(qemu_nbd.clear({"/mnt/foo": "/dev/nbd0p1"}),
                              {})
示例#2
0
 def test_clear(self):
     '''
     Test if it pass in the mnt dict returned from nbd_mount
     to unmount and disconnect the image from nbd.
     '''
     mock_run = MagicMock(return_value=True)
     with patch.dict(qemu_nbd.__salt__,
                     {'cmd.run': mock_run,
                      'mount.umount': MagicMock(side_effect=[False, True])}):
         self.assertDictEqual(qemu_nbd.clear({"/mnt/foo": "/dev/nbd0p1"}),
                              {'/mnt/foo': '/dev/nbd0p1'})
         self.assertDictEqual(qemu_nbd.clear({"/mnt/foo": "/dev/nbd0p1"}),
                              {})
def test_clear():
    """
    Test if it pass in the mnt dict returned from nbd_mount
    to unmount and disconnect the image from nbd.
    """
    mock_run = MagicMock(return_value=True)
    with patch.dict(
        qemu_nbd.__salt__,
        {"cmd.run": mock_run, "mount.umount": MagicMock(side_effect=[False, True])},
    ):
        assert qemu_nbd.clear({"/mnt/foo": "/dev/nbd0p1"}) == {
            "/mnt/foo": "/dev/nbd0p1"
        }
        assert qemu_nbd.clear({"/mnt/foo": "/dev/nbd0p1"}) == {}