mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge branch '2018.3' into win_disks
This commit is contained in:
commit
057d415d23
8 changed files with 86 additions and 15 deletions
|
@ -202,7 +202,7 @@ execution modules
|
|||
keystone
|
||||
keystoneng
|
||||
kmod
|
||||
kubernetes
|
||||
kubernetesmod
|
||||
launchctl_service
|
||||
layman
|
||||
ldap3
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
=======================
|
||||
salt.modules.kubernetes
|
||||
=======================
|
||||
|
||||
.. automodule:: salt.modules.kubernetes
|
||||
:members:
|
6
doc/ref/modules/all/salt.modules.kubernetesmod.rst
Normal file
6
doc/ref/modules/all/salt.modules.kubernetesmod.rst
Normal file
|
@ -0,0 +1,6 @@
|
|||
==========================
|
||||
salt.modules.kubernetesmod
|
||||
==========================
|
||||
|
||||
.. automodule:: salt.modules.kubernetesmod
|
||||
:members:
|
|
@ -710,7 +710,7 @@ Execution modules
|
|||
- :mod:`salt.modules.grafana4 <salt.modules.grafana4>`
|
||||
- :mod:`salt.modules.heat <salt.modules.heat>`
|
||||
- :mod:`salt.modules.icinga2 <salt.modules.icinga2>`
|
||||
- :mod:`salt.modules.kubernetes <salt.modules.kubernetes>`
|
||||
- :mod:`salt.modules.kubernetesmod <salt.modules.kubernetesmod>`
|
||||
- :mod:`salt.modules.logmod <salt.modules.logmod>`
|
||||
- :mod:`salt.modules.mattermost <salt.modules.mattermost>`
|
||||
- :mod:`salt.modules.namecheap_dns <salt.modules.namecheap_dns>`
|
||||
|
|
|
@ -4,7 +4,7 @@ Manage kubernetes resources as salt states
|
|||
==========================================
|
||||
|
||||
NOTE: This module requires the proper pillar values set. See
|
||||
salt.modules.kubernetes for more information.
|
||||
salt.modules.kubernetesmod for more information.
|
||||
|
||||
.. warning::
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ from tests.support.mock import (
|
|||
NO_MOCK_REASON
|
||||
)
|
||||
|
||||
from salt.modules import kubernetes
|
||||
from salt.modules import kubernetesmod as kubernetes
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
@ -28,7 +28,7 @@ def mock_kubernetes_library():
|
|||
it caused kubernetes._cleanup() to get called for virtually every
|
||||
test, which blows up. This prevents that specific blow-up once
|
||||
"""
|
||||
with patch('salt.modules.kubernetes.kubernetes') as mock_kubernetes_lib:
|
||||
with patch('salt.modules.kubernetesmod.kubernetes') as mock_kubernetes_lib:
|
||||
mock_kubernetes_lib.client.configuration.ssl_ca_cert = ''
|
||||
mock_kubernetes_lib.client.configuration.cert_file = ''
|
||||
mock_kubernetes_lib.client.configuration.key_file = ''
|
||||
|
@ -40,7 +40,7 @@ def mock_kubernetes_library():
|
|||
"Skipping test_kubernetes.py")
|
||||
class KubernetesTestCase(TestCase, LoaderModuleMockMixin):
|
||||
'''
|
||||
Test cases for salt.modules.kubernetes
|
||||
Test cases for salt.modules.kubernetesmod
|
||||
'''
|
||||
|
||||
def setup_loader_modules(self):
|
||||
|
@ -114,7 +114,7 @@ class KubernetesTestCase(TestCase, LoaderModuleMockMixin):
|
|||
:return:
|
||||
'''
|
||||
with mock_kubernetes_library() as mock_kubernetes_lib:
|
||||
with patch('salt.modules.kubernetes.show_deployment', Mock(return_value=None)):
|
||||
with patch('salt.modules.kubernetesmod.show_deployment', Mock(return_value=None)):
|
||||
with patch.dict(kubernetes.__salt__, {'config.option': Mock(return_value="")}):
|
||||
mock_kubernetes_lib.client.V1DeleteOptions = Mock(return_value="")
|
||||
mock_kubernetes_lib.client.ExtensionsV1beta1Api.return_value = Mock(
|
||||
|
@ -164,7 +164,7 @@ class KubernetesTestCase(TestCase, LoaderModuleMockMixin):
|
|||
Test kubernetes.node_labels
|
||||
:return:
|
||||
'''
|
||||
with patch('salt.modules.kubernetes.node') as mock_node:
|
||||
with patch('salt.modules.kubernetesmod.node') as mock_node:
|
||||
mock_node.return_value = {
|
||||
'metadata': {
|
||||
'labels': {
|
||||
|
@ -184,7 +184,7 @@ class KubernetesTestCase(TestCase, LoaderModuleMockMixin):
|
|||
kubectl [apply|create|replace] --record does
|
||||
:return:
|
||||
'''
|
||||
with patch('salt.modules.kubernetes.sys.argv', ['/usr/bin/salt-call', 'state.apply']) as mock_sys:
|
||||
with patch('salt.modules.kubernetesmod.sys.argv', ['/usr/bin/salt-call', 'state.apply']) as mock_sys:
|
||||
func = getattr(kubernetes, '__dict_to_object_meta')
|
||||
data = func(name='test-pod', namespace='test', metadata={})
|
||||
|
71
tests/unit/test__compat.py
Normal file
71
tests/unit/test__compat.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Unit tests for salt._compat
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import sys
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
# Import Salt libs
|
||||
import salt._compat as compat
|
||||
|
||||
# Import 3rd Party libs
|
||||
from salt.ext.six import binary_type, text_type
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
PY3 = sys.version_info.major == 3
|
||||
|
||||
|
||||
class CompatTestCase(TestCase):
|
||||
def test_text(self):
|
||||
ret = compat.text_('test string')
|
||||
self.assertTrue(isinstance(ret, text_type))
|
||||
|
||||
def test_text_binary(self):
|
||||
ret = compat.text_(b'test string')
|
||||
self.assertTrue(isinstance(ret, text_type))
|
||||
|
||||
def test_bytes(self):
|
||||
ret = compat.bytes_('test string')
|
||||
self.assertTrue(isinstance(ret, binary_type))
|
||||
|
||||
def test_bytes_binary(self):
|
||||
ret = compat.bytes_(b'test string')
|
||||
self.assertTrue(isinstance(ret, binary_type))
|
||||
|
||||
def test_ascii_native(self):
|
||||
ret = compat.ascii_native_('test string')
|
||||
self.assertTrue(isinstance(ret, str))
|
||||
|
||||
def test_ascii_native_binary(self):
|
||||
ret = compat.ascii_native_(b'test string')
|
||||
self.assertTrue(isinstance(ret, str))
|
||||
|
||||
def test_native(self):
|
||||
ret = compat.native_('test string')
|
||||
self.assertTrue(isinstance(ret, str))
|
||||
|
||||
def test_native_binary(self):
|
||||
ret = compat.native_(b'test string')
|
||||
self.assertTrue(isinstance(ret, str))
|
||||
|
||||
def test_string_io(self):
|
||||
ret = compat.string_io('test string')
|
||||
if PY3:
|
||||
expected = 'io.StringIO object'
|
||||
else:
|
||||
expected = 'cStringIO.StringI object'
|
||||
self.assertTrue(expected in repr(ret))
|
||||
|
||||
def test_string_io_unicode(self):
|
||||
ret = compat.string_io(u'test string \xf8')
|
||||
if PY3:
|
||||
expected = 'io.StringIO object'
|
||||
else:
|
||||
expected = 'StringIO.StringIO instance'
|
||||
self.assertTrue(expected in repr(ret))
|
Loading…
Add table
Reference in a new issue