From 65dba3e9ab088087943f67367dc27fce00e4cd92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= Date: Tue, 13 Sep 2016 11:05:35 +0100 Subject: [PATCH 20/20] Integration tests fixes for 2016.3.2 * Fix PillarModuleTest::test_pillar_items: 'info' does not exist in pillar * Fixing integration tests if azure is not present * Fixing integration tests failures if 'git' command is missing Skip git state integration tests if 'git' does not exists Prevent OSError if 'git' command not found during _git_version() --- tests/integration/cloud/providers/msazure.py | 17 +++++++++-------- tests/integration/modules/git.py | 15 +++++++++------ tests/integration/modules/pillar.py | 1 - tests/integration/states/git.py | 2 +- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/integration/cloud/providers/msazure.py b/tests/integration/cloud/providers/msazure.py index c4934e4..4e53add 100644 --- a/tests/integration/cloud/providers/msazure.py +++ b/tests/integration/cloud/providers/msazure.py @@ -53,14 +53,15 @@ def __has_required_azure(): ''' Returns True/False if the required version of the Azure SDK is installed. ''' - if hasattr(azure, '__version__'): - version = LooseVersion(azure.__version__) - else: - version = LooseVersion(azure.common.__version__) - if HAS_AZURE is True and REQUIRED_AZURE <= version: - return True - else: - return False + if HAS_AZURE: + if hasattr(azure, '__version__'): + version = LooseVersion(azure.__version__) + else: + version = LooseVersion(azure.common.__version__) + + if REQUIRED_AZURE <= version: + return True + return False @skipIf(HAS_AZURE is False, 'These tests require the Azure Python SDK to be installed.') diff --git a/tests/integration/modules/git.py b/tests/integration/modules/git.py index 7c40664..f5c15f3 100644 --- a/tests/integration/modules/git.py +++ b/tests/integration/modules/git.py @@ -36,12 +36,15 @@ log = logging.getLogger(__name__) def _git_version(): - git_version = subprocess.Popen( - ['git', '--version'], - shell=False, - close_fds=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE).communicate()[0] + try: + git_version = subprocess.Popen( + ['git', '--version'], + shell=False, + close_fds=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate()[0] + except OSError: + return False if not git_version: log.debug('Git not installed') return False diff --git a/tests/integration/modules/pillar.py b/tests/integration/modules/pillar.py index b081f76..3d55b4c 100644 --- a/tests/integration/modules/pillar.py +++ b/tests/integration/modules/pillar.py @@ -119,7 +119,6 @@ class PillarModuleTest(integration.ModuleCase): from pillar.items ''' get_items = self.run_function('pillar.items') - self.assertDictContainsSubset({'info': 'bar'}, get_items) self.assertDictContainsSubset({'monty': 'python'}, get_items) self.assertDictContainsSubset( {'knights': ['Lancelot', 'Galahad', 'Bedevere', 'Robin']}, diff --git a/tests/integration/states/git.py b/tests/integration/states/git.py index a78b271..87681ba 100644 --- a/tests/integration/states/git.py +++ b/tests/integration/states/git.py @@ -20,6 +20,7 @@ import integration import salt.utils +@skip_if_binaries_missing('git') class GitTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): ''' Validate the git state @@ -254,7 +255,6 @@ class GitTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): finally: shutil.rmtree(name, ignore_errors=True) - @skip_if_binaries_missing('git') def test_config_set_value_with_space_character(self): ''' git.config -- 2.8.2