mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #43402 from twangboy/win_unit_test_qemu_nbd
Fix `unit.modules.test_qemu_nbd` for Windows
This commit is contained in:
commit
c0f54bfef1
1 changed files with 8 additions and 9 deletions
|
@ -80,15 +80,14 @@ class QemuNbdTestCase(TestCase, LoaderModuleMockMixin):
|
|||
with patch.dict(qemu_nbd.__salt__, {'cmd.run': mock}):
|
||||
self.assertEqual(qemu_nbd.init('/srv/image.qcow2'), '')
|
||||
|
||||
with patch.object(os.path, 'isfile', mock):
|
||||
with patch.object(glob, 'glob',
|
||||
MagicMock(return_value=['/dev/nbd0'])):
|
||||
with patch.dict(qemu_nbd.__salt__,
|
||||
{'cmd.run': mock,
|
||||
'mount.mount': mock,
|
||||
'cmd.retcode': MagicMock(side_effect=[1, 0])}):
|
||||
self.assertDictEqual(qemu_nbd.init('/srv/image.qcow2'),
|
||||
{'{0}/nbd/nbd0/nbd0'.format(tempfile.gettempdir()): '/dev/nbd0'})
|
||||
with patch.object(os.path, 'isfile', mock),\
|
||||
patch.object(glob, 'glob', MagicMock(return_value=['/dev/nbd0'])),\
|
||||
patch.dict(qemu_nbd.__salt__,
|
||||
{'cmd.run': mock,
|
||||
'mount.mount': mock,
|
||||
'cmd.retcode': MagicMock(side_effect=[1, 0])}):
|
||||
expected = {os.sep.join([tempfile.gettempdir(), 'nbd', 'nbd0', 'nbd0']): '/dev/nbd0'}
|
||||
self.assertDictEqual(qemu_nbd.init('/srv/image.qcow2'), expected)
|
||||
|
||||
# 'clear' function tests: 1
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue