mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Requested changes. Additional test for the False state.
This commit is contained in:
parent
cedcddeac0
commit
0ddb93995b
3 changed files with 17 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
Moving import salt.modules.vsphere into virtual so we have access to test proxytype in opts,
|
||||
previously this was causing a traceback when run on proxy minion as __opts__ does not exist
|
||||
Moving import salt.modules.vsphere into `__virtual__` so we have access to test proxytype in opts,
|
||||
previously this was causing a traceback when run on proxy minion as `__opts__` does not exist
|
||||
outside of any functions. Introducing a new utils function, is_proxytype, to check that the
|
||||
device is a proxy minion and also that the proxy type matches.
|
||||
|
|
|
@ -5,14 +5,11 @@
|
|||
:codeauthor: :email:`Gareth J. Greenaway <gareth@saltstack.com>`
|
||||
"""
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
import salt.grains.esxi as esxi_grains
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.mock import patch
|
||||
from tests.support.unit import TestCase
|
||||
|
|
|
@ -4,19 +4,15 @@
|
|||
:codeauthor: :email:`Gareth J. Greenaway <gareth@saltstack.com>`
|
||||
"""
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.proxy
|
||||
from tests.support.mock import patch
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
|
||||
class ProxyUtilsTestCase(TestCase):
|
||||
def test_is_proxytype(self):
|
||||
def test_is_proxytype_true(self):
|
||||
opts = {
|
||||
"proxy": {
|
||||
"proxytype": "esxi",
|
||||
|
@ -29,3 +25,17 @@ class ProxyUtilsTestCase(TestCase):
|
|||
with patch("salt.utils.platform.is_proxy", return_value=True, autospec=True):
|
||||
ret = salt.utils.proxy.is_proxytype(opts, "esxi")
|
||||
self.assertTrue(ret)
|
||||
|
||||
def test_is_proxytype_false(self):
|
||||
opts = {
|
||||
"proxy": {
|
||||
"proxytype": "esxi",
|
||||
"host": "esxi.domain.com",
|
||||
"username": "username",
|
||||
"passwords": ["password1"],
|
||||
}
|
||||
}
|
||||
|
||||
with patch("salt.utils.platform.is_proxy", return_value=True, autospec=True):
|
||||
ret = salt.utils.proxy.is_proxytype(opts, "docker")
|
||||
self.assertFalse(ret)
|
||||
|
|
Loading…
Add table
Reference in a new issue