salt/tests/unit/modules/test_guestfs.py

41 lines
1.1 KiB
Python
Raw Normal View History

2015-01-29 08:48:38 +00:00
# -*- coding: utf-8 -*-
'''
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
2015-01-29 08:48:38 +00:00
'''
2015-01-30 18:00:04 +00:00
# Import Python libs
from __future__ import absolute_import
2015-01-29 08:48:38 +00:00
# Import Salt Testing Libs
2017-02-19 15:35:30 +00:00
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import TestCase, skipIf
from tests.support.mock import (
2015-01-29 08:48:38 +00:00
MagicMock,
patch,
NO_MOCK,
NO_MOCK_REASON
)
# Import Salt Libs
import salt.modules.guestfs as guestfs
2015-01-29 08:48:38 +00:00
@skipIf(NO_MOCK, NO_MOCK_REASON)
2017-02-19 15:35:30 +00:00
class GuestfsTestCase(TestCase, LoaderModuleMockMixin):
2015-01-29 08:48:38 +00:00
'''
Test cases for salt.modules.guestfs
'''
def setup_loader_modules(self):
return {guestfs: {}}
2017-02-19 15:35:30 +00:00
2015-01-29 08:48:38 +00:00
# 'mount' function tests: 1
def test_mount(self):
'''
Test if it mount an image
'''
2017-04-10 13:00:57 +00:00
with patch('os.path.join', MagicMock(return_value=True)), \
patch('os.path.isdir', MagicMock(return_value=True)), \
patch('os.listdir', MagicMock(return_value=False)), \
patch.dict(guestfs.__salt__, {'cmd.run': MagicMock(return_value='')}):
2015-01-29 08:48:38 +00:00
self.assertTrue(guestfs.mount('/srv/images/fedora.qcow'))