mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #19273 from jayeshka/extfs_unit_tests
adding extfs unit test
This commit is contained in:
commit
621bcee92d
75
tests/unit/modules/extfs_test.py
Normal file
75
tests/unit/modules/extfs_test.py
Normal file
@ -0,0 +1,75 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
||||
'''
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from salttesting import TestCase, skipIf
|
||||
from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.modules import extfs
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class ExtfsTestCase(TestCase):
|
||||
'''
|
||||
TestCase for salt.modules.extfs
|
||||
'''
|
||||
extfs.__salt__ = {}
|
||||
|
||||
# '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'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
run_tests(ExtfsTestCase, needs_daemon=False)
|
Loading…
Reference in New Issue
Block a user