Fix skipping Kubernetes tests if client is not installed

When the Kubernetes client is not installed, the import of
salt.modules.kubernetes will still succeed, but HAS_LIBS will be set to
False (since the library import will be covered by a try-except clause).

Therefore expect the salt.modules.kubernetes to always succeed and check
kubernetes.HAS_LIBS instead for the presence of the kubernetes library.

Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com>
This commit is contained in:
Benjamin Drung 2018-02-19 12:32:14 +01:00
parent c3a938e994
commit dd3f936557

View file

@ -16,15 +16,12 @@ from tests.support.mock import (
NO_MOCK_REASON
)
try:
from salt.modules import kubernetes
except ImportError:
kubernetes = False
from salt.modules import kubernetes
@skipIf(NO_MOCK, NO_MOCK_REASON)
@skipIf(kubernetes is False, "Probably Kubernetes client lib is not installed. \
Skipping test_kubernetes.py")
@skipIf(not kubernetes.HAS_LIBS, "Kubernetes client lib is not installed. "
"Skipping test_kubernetes.py")
class KubernetesTestCase(TestCase, LoaderModuleMockMixin):
'''
Test cases for salt.modules.kubernetes