mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
migrate test_pecl to pytest
This commit is contained in:
parent
2bb2604f74
commit
6d765017ae
2 changed files with 53 additions and 47 deletions
53
tests/pytests/unit/modules/test_pecl.py
Normal file
53
tests/pytests/unit/modules/test_pecl.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
"""
|
||||
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
|
||||
|
||||
Test cases for salt.modules.pecl
|
||||
"""
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.modules.pecl as pecl
|
||||
from tests.support.mock import patch
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def configure_loader_modules():
|
||||
return {pecl: {}}
|
||||
|
||||
|
||||
def test_install():
|
||||
"""
|
||||
Test to installs one or several pecl extensions.
|
||||
"""
|
||||
with patch.object(pecl, "_pecl", return_value="A"):
|
||||
assert pecl.install("fuse", force=True) == "A"
|
||||
|
||||
assert not pecl.install("fuse")
|
||||
|
||||
with patch.object(pecl, "list_", return_value={"A": ["A", "B"]}):
|
||||
assert pecl.install(["A", "B"])
|
||||
|
||||
|
||||
def test_uninstall():
|
||||
"""
|
||||
Test to uninstall one or several pecl extensions.
|
||||
"""
|
||||
with patch.object(pecl, "_pecl", return_value="A"):
|
||||
assert pecl.uninstall("fuse") == "A"
|
||||
|
||||
|
||||
def test_update():
|
||||
"""
|
||||
Test to update one or several pecl extensions.
|
||||
"""
|
||||
with patch.object(pecl, "_pecl", return_value="A"):
|
||||
assert pecl.update("fuse") == "A"
|
||||
|
||||
|
||||
def test_list_():
|
||||
"""
|
||||
Test to list installed pecl extensions.
|
||||
"""
|
||||
with patch.object(pecl, "_pecl", return_value="A\nB"):
|
||||
assert pecl.list_("channel") == {}
|
|
@ -1,47 +0,0 @@
|
|||
"""
|
||||
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
|
||||
"""
|
||||
|
||||
|
||||
import salt.modules.pecl as pecl
|
||||
from tests.support.mock import patch
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
|
||||
class PeclTestCase(TestCase):
|
||||
"""
|
||||
Test cases for salt.modules.pecl
|
||||
"""
|
||||
|
||||
def test_install(self):
|
||||
"""
|
||||
Test to installs one or several pecl extensions.
|
||||
"""
|
||||
with patch.object(pecl, "_pecl", return_value="A"):
|
||||
self.assertEqual(pecl.install("fuse", force=True), "A")
|
||||
|
||||
self.assertFalse(pecl.install("fuse"))
|
||||
|
||||
with patch.object(pecl, "list_", return_value={"A": ["A", "B"]}):
|
||||
self.assertTrue(pecl.install(["A", "B"]))
|
||||
|
||||
def test_uninstall(self):
|
||||
"""
|
||||
Test to uninstall one or several pecl extensions.
|
||||
"""
|
||||
with patch.object(pecl, "_pecl", return_value="A"):
|
||||
self.assertEqual(pecl.uninstall("fuse"), "A")
|
||||
|
||||
def test_update(self):
|
||||
"""
|
||||
Test to update one or several pecl extensions.
|
||||
"""
|
||||
with patch.object(pecl, "_pecl", return_value="A"):
|
||||
self.assertEqual(pecl.update("fuse"), "A")
|
||||
|
||||
def test_list_(self):
|
||||
"""
|
||||
Test to list installed pecl extensions.
|
||||
"""
|
||||
with patch.object(pecl, "_pecl", return_value="A\nB"):
|
||||
self.assertDictEqual(pecl.list_("channel"), {})
|
Loading…
Add table
Reference in a new issue