mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
migrate test_bigip to pytest
This commit is contained in:
parent
ea1f030905
commit
379119f731
2 changed files with 38 additions and 37 deletions
38
tests/pytests/unit/modules/test_bigip.py
Normal file
38
tests/pytests/unit/modules/test_bigip.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
"""
|
||||
tests.unit.modules.test_bigip
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Unit tests for the bigip module
|
||||
"""
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.modules.bigip as bigip
|
||||
from tests.support.mock import MagicMock, patch
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RequestsSession:
|
||||
def __init__(self):
|
||||
self.auth = None
|
||||
self.verify = None
|
||||
self.headers = {}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def configure_loader_modules():
|
||||
return {bigip: {}}
|
||||
|
||||
|
||||
def test__build_session_verify_ssl():
|
||||
requests_session = RequestsSession()
|
||||
with patch(
|
||||
"salt.modules.bigip.requests.sessions.Session",
|
||||
MagicMock(return_value=requests_session),
|
||||
):
|
||||
bigip._build_session("username", "password")
|
||||
|
||||
assert requests_session.auth == ("username", "password")
|
||||
assert requests_session.verify is True
|
|
@ -1,37 +0,0 @@
|
|||
"""
|
||||
tests.unit.modules.test_bigip
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Unit tests for the bigip module
|
||||
"""
|
||||
import logging
|
||||
|
||||
import salt.modules.bigip as bigip
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.mock import MagicMock, patch
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RequestsSession:
|
||||
def __init__(self):
|
||||
self.auth = None
|
||||
self.verify = None
|
||||
self.headers = {}
|
||||
|
||||
|
||||
class BigipModuleTest(TestCase, LoaderModuleMockMixin):
|
||||
def setup_loader_modules(self):
|
||||
return {bigip: {}}
|
||||
|
||||
def test__build_session_verify_ssl(self):
|
||||
requests_session = RequestsSession()
|
||||
with patch(
|
||||
"salt.modules.bigip.requests.sessions.Session",
|
||||
MagicMock(return_value=requests_session),
|
||||
):
|
||||
bigip._build_session("username", "password")
|
||||
|
||||
self.assertEqual(requests_session.auth, ("username", "password"))
|
||||
assert requests_session.verify is True
|
Loading…
Add table
Reference in a new issue