salt/tests/unit/modules/test_extfs.py

77 lines
2.1 KiB
Python
Raw Normal View History

2014-12-29 13:59:41 +00:00
# -*- coding: utf-8 -*-
'''
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
'''
2015-01-08 02:28:16 +00:00
# Import Python libs
from __future__ import absolute_import
2014-12-29 13:59:41 +00:00
# Import Salt Testing Libs
2017-03-29 00:22:57 +00:00
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import TestCase, skipIf
from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON
2014-12-29 13:59:41 +00:00
# Import Salt Libs
import salt.modules.extfs as extfs
2014-12-29 13:59:41 +00:00
@skipIf(NO_MOCK, NO_MOCK_REASON)
2017-03-29 00:22:57 +00:00
class ExtfsTestCase(TestCase, LoaderModuleMockMixin):
2014-12-29 13:59:41 +00:00
'''
TestCase for salt.modules.extfs
'''
2017-03-29 00:22:57 +00:00
def setup_loader_modules(self):
return {extfs: {}}
2014-12-29 13:59:41 +00:00
# 'mkfs' function tests: 1
def test_mkfs(self):
'''
Tests if a file system created on the specified device
'''
mock = MagicMock()
with patch.dict(extfs.__salt__, {'cmd.run': mock}):
self.assertListEqual([], extfs.mkfs('/dev/sda1', 'ext4'))
# 'tune' function tests: 1
@patch('salt.modules.extfs.tune', MagicMock(return_value=''))
def test_tune(self):
'''
Tests if specified group was added
'''
mock = MagicMock()
with patch.dict(extfs.__salt__, {'cmd.run': mock}):
self.assertEqual('', extfs.tune('/dev/sda1'))
# 'dump' function tests: 1
def test_dump(self):
'''
Tests if specified group was added
'''
mock = MagicMock()
with patch.dict(extfs.__salt__, {'cmd.run': mock}):
self.assertEqual({'attributes': {}, 'blocks': {}},
extfs.dump('/dev/sda1'))
# 'attributes' function tests: 1
@patch('salt.modules.extfs.dump',
MagicMock(return_value={'attributes': {}, 'blocks': {}}))
def test_attributes(self):
'''
Tests if specified group was added
'''
self.assertEqual({}, extfs.attributes('/dev/sda1'))
# 'blocks' function tests: 1
@patch('salt.modules.extfs.dump',
MagicMock(return_value={'attributes': {}, 'blocks': {}}))
def test_blocks(self):
'''
Tests if specified group was added
'''
self.assertEqual({}, extfs.blocks('/dev/sda1'))