mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
migrate test_key to pytest
This commit is contained in:
parent
b7da9d2ef2
commit
72d346501f
2 changed files with 42 additions and 42 deletions
42
tests/pytests/unit/modules/test_key.py
Normal file
42
tests/pytests/unit/modules/test_key.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
"""
|
||||
:codeauthor: Rupesh Tare <rupesht@saltstack.com>
|
||||
|
||||
Test cases for salt.modules.key
|
||||
"""
|
||||
|
||||
|
||||
import os.path
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.modules.key as key
|
||||
import salt.utils.crypt
|
||||
from tests.support.mock import MagicMock, patch
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def configure_loader_modules():
|
||||
return {key: {}}
|
||||
|
||||
|
||||
def test_finger():
|
||||
"""
|
||||
Test for finger
|
||||
"""
|
||||
with patch.object(os.path, "join", return_value="A"):
|
||||
with patch.object(salt.utils.crypt, "pem_finger", return_value="A"):
|
||||
with patch.dict(
|
||||
key.__opts__,
|
||||
{"pki_dir": MagicMock(return_value="A"), "hash_type": "sha256"},
|
||||
):
|
||||
assert key.finger() == "A"
|
||||
|
||||
|
||||
def test_finger_master():
|
||||
"""
|
||||
Test for finger
|
||||
"""
|
||||
with patch.object(os.path, "join", return_value="A"):
|
||||
with patch.object(salt.utils.crypt, "pem_finger", return_value="A"):
|
||||
with patch.dict(key.__opts__, {"pki_dir": "A", "hash_type": "sha256"}):
|
||||
assert key.finger_master() == "A"
|
|
@ -1,42 +0,0 @@
|
|||
"""
|
||||
:codeauthor: Rupesh Tare <rupesht@saltstack.com>
|
||||
"""
|
||||
|
||||
|
||||
import os.path
|
||||
|
||||
import salt.modules.key as key
|
||||
import salt.utils.crypt
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.mock import MagicMock, patch
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
|
||||
class KeyTestCase(TestCase, LoaderModuleMockMixin):
|
||||
"""
|
||||
Test cases for salt.modules.key
|
||||
"""
|
||||
|
||||
def setup_loader_modules(self):
|
||||
return {key: {}}
|
||||
|
||||
def test_finger(self):
|
||||
"""
|
||||
Test for finger
|
||||
"""
|
||||
with patch.object(os.path, "join", return_value="A"):
|
||||
with patch.object(salt.utils.crypt, "pem_finger", return_value="A"):
|
||||
with patch.dict(
|
||||
key.__opts__,
|
||||
{"pki_dir": MagicMock(return_value="A"), "hash_type": "sha256"},
|
||||
):
|
||||
self.assertEqual(key.finger(), "A")
|
||||
|
||||
def test_finger_master(self):
|
||||
"""
|
||||
Test for finger
|
||||
"""
|
||||
with patch.object(os.path, "join", return_value="A"):
|
||||
with patch.object(salt.utils.crypt, "pem_finger", return_value="A"):
|
||||
with patch.dict(key.__opts__, {"pki_dir": "A", "hash_type": "sha256"}):
|
||||
self.assertEqual(key.finger_master(), "A")
|
Loading…
Add table
Reference in a new issue