salt/tests/unit/modules/test_guestfs.py

42 lines
998 B
Python
Raw Normal View History

2015-01-29 08:48:38 +00:00
# -*- coding: utf-8 -*-
'''
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
'''
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
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
from salt.modules import guestfs
# Globals
guestfs.__salt__ = {}
@skipIf(NO_MOCK, NO_MOCK_REASON)
class GuestfsTestCase(TestCase):
'''
Test cases for salt.modules.guestfs
'''
# 'mount' function tests: 1
@patch('os.path.join', MagicMock(return_value=True))
@patch('os.path.isdir', MagicMock(return_value=True))
@patch('os.listdir', MagicMock(return_value=False))
def test_mount(self):
'''
Test if it mount an image
'''
mock = MagicMock(return_value='')
with patch.dict(guestfs.__salt__, {'cmd.run': mock}):
self.assertTrue(guestfs.mount('/srv/images/fedora.qcow'))