mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
migrate test_nfs3 to pytest
This commit is contained in:
parent
c48d6c94cd
commit
e840234093
2 changed files with 39 additions and 39 deletions
39
tests/pytests/unit/modules/test_nfs3.py
Normal file
39
tests/pytests/unit/modules/test_nfs3.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
"""
|
||||
:codeauthor: Rahul Handay <rahulha@saltstack.com>
|
||||
|
||||
Test cases for salt.modules.nfs3
|
||||
"""
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.modules.nfs3 as nfs3
|
||||
from tests.support.mock import MagicMock, mock_open, patch
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def configure_loader_modules():
|
||||
return {nfs3: {}}
|
||||
|
||||
|
||||
def test_list_exports():
|
||||
"""
|
||||
Test for List configured exports
|
||||
"""
|
||||
with patch("salt.utils.files.fopen", mock_open(read_data="A B1(23")):
|
||||
exports = nfs3.list_exports()
|
||||
assert exports == {"A": [{"hosts": "B1", "options": ["23"]}]}, exports
|
||||
|
||||
|
||||
def test_del_export():
|
||||
"""
|
||||
Test for Remove an export
|
||||
"""
|
||||
list_exports_mock = MagicMock(
|
||||
return_value={"A": [{"hosts": ["B1"], "options": ["23"]}]}
|
||||
)
|
||||
with patch.object(nfs3, "list_exports", list_exports_mock), patch.object(
|
||||
nfs3, "_write_exports", MagicMock(return_value=None)
|
||||
):
|
||||
result = nfs3.del_export(path="A")
|
||||
assert result == {}, result
|
|
@ -1,39 +0,0 @@
|
|||
"""
|
||||
:codeauthor: Rahul Handay <rahulha@saltstack.com>
|
||||
"""
|
||||
|
||||
|
||||
import salt.modules.nfs3 as nfs3
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.mock import MagicMock, mock_open, patch
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
|
||||
class NfsTestCase(TestCase, LoaderModuleMockMixin):
|
||||
"""
|
||||
Test cases for salt.modules.nfs3
|
||||
"""
|
||||
|
||||
def setup_loader_modules(self):
|
||||
return {nfs3: {}}
|
||||
|
||||
def test_list_exports(self):
|
||||
"""
|
||||
Test for List configured exports
|
||||
"""
|
||||
with patch("salt.utils.files.fopen", mock_open(read_data="A B1(23")):
|
||||
exports = nfs3.list_exports()
|
||||
assert exports == {"A": [{"hosts": "B1", "options": ["23"]}]}, exports
|
||||
|
||||
def test_del_export(self):
|
||||
"""
|
||||
Test for Remove an export
|
||||
"""
|
||||
list_exports_mock = MagicMock(
|
||||
return_value={"A": [{"hosts": ["B1"], "options": ["23"]}]}
|
||||
)
|
||||
with patch.object(nfs3, "list_exports", list_exports_mock), patch.object(
|
||||
nfs3, "_write_exports", MagicMock(return_value=None)
|
||||
):
|
||||
result = nfs3.del_export(path="A")
|
||||
assert result == {}, result
|
Loading…
Add table
Reference in a new issue