mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
migrate test_rdp to pytest
This commit is contained in:
parent
2bb2604f74
commit
01e96bc293
2 changed files with 56 additions and 52 deletions
56
tests/pytests/unit/modules/test_rdp.py
Normal file
56
tests/pytests/unit/modules/test_rdp.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
"""
|
||||
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
|
||||
|
||||
Test cases for salt.modules.rdp
|
||||
"""
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.modules.rdp as rdp
|
||||
from tests.support.mock import MagicMock, patch
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def configure_loader_modules():
|
||||
return {rdp: {}}
|
||||
|
||||
|
||||
# 'enable' function tests: 1
|
||||
|
||||
|
||||
def test_enable():
|
||||
"""
|
||||
Test if it enables RDP the service on the server
|
||||
"""
|
||||
mock = MagicMock(return_value=True)
|
||||
with patch.dict(rdp.__salt__, {"cmd.run": mock}), patch(
|
||||
"salt.modules.rdp._parse_return_code_powershell", MagicMock(return_value=0)
|
||||
):
|
||||
assert rdp.enable()
|
||||
|
||||
|
||||
# 'disable' function tests: 1
|
||||
|
||||
|
||||
def test_disable():
|
||||
"""
|
||||
Test if it disables RDP the service on the server
|
||||
"""
|
||||
mock = MagicMock(return_value=True)
|
||||
with patch.dict(rdp.__salt__, {"cmd.run": mock}), patch(
|
||||
"salt.modules.rdp._parse_return_code_powershell", MagicMock(return_value=0)
|
||||
):
|
||||
assert rdp.disable()
|
||||
|
||||
|
||||
# 'status' function tests: 1
|
||||
|
||||
|
||||
def test_status():
|
||||
"""
|
||||
Test if it shows rdp is enabled on the server
|
||||
"""
|
||||
mock = MagicMock(return_value="1")
|
||||
with patch.dict(rdp.__salt__, {"cmd.run": mock}):
|
||||
assert rdp.status()
|
|
@ -1,52 +0,0 @@
|
|||
"""
|
||||
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
|
||||
"""
|
||||
|
||||
|
||||
import salt.modules.rdp as rdp
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.mock import MagicMock, patch
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
|
||||
class RdpTestCase(TestCase, LoaderModuleMockMixin):
|
||||
"""
|
||||
Test cases for salt.modules.rdp
|
||||
"""
|
||||
|
||||
def setup_loader_modules(self):
|
||||
return {rdp: {}}
|
||||
|
||||
# 'enable' function tests: 1
|
||||
|
||||
def test_enable(self):
|
||||
"""
|
||||
Test if it enables RDP the service on the server
|
||||
"""
|
||||
mock = MagicMock(return_value=True)
|
||||
with patch.dict(rdp.__salt__, {"cmd.run": mock}), patch(
|
||||
"salt.modules.rdp._parse_return_code_powershell", MagicMock(return_value=0)
|
||||
):
|
||||
self.assertTrue(rdp.enable())
|
||||
|
||||
# 'disable' function tests: 1
|
||||
|
||||
def test_disable(self):
|
||||
"""
|
||||
Test if it disables RDP the service on the server
|
||||
"""
|
||||
mock = MagicMock(return_value=True)
|
||||
with patch.dict(rdp.__salt__, {"cmd.run": mock}), patch(
|
||||
"salt.modules.rdp._parse_return_code_powershell", MagicMock(return_value=0)
|
||||
):
|
||||
self.assertTrue(rdp.disable())
|
||||
|
||||
# 'status' function tests: 1
|
||||
|
||||
def test_status(self):
|
||||
"""
|
||||
Test if it shows rdp is enabled on the server
|
||||
"""
|
||||
mock = MagicMock(return_value="1")
|
||||
with patch.dict(rdp.__salt__, {"cmd.run": mock}):
|
||||
self.assertTrue(rdp.status())
|
Loading…
Add table
Reference in a new issue