From 489977b2de4fd448705debb2a48d65ad41650bca Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Mon, 19 Mar 2018 09:51:37 +0100 Subject: Fix regex when INSTALLER_TYPE is unset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0ec012185f3c90b2a2c82b6f204ce332f3fa9c7f Signed-off-by: Cédric Ollivier --- xtesting/ci/tier_handler.py | 18 ++++++++---------- xtesting/tests/unit/ci/test_tier_handler.py | 16 ++++++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/xtesting/ci/tier_handler.py b/xtesting/ci/tier_handler.py index 9fc3f24d..915985f5 100644 --- a/xtesting/ci/tier_handler.py +++ b/xtesting/ci/tier_handler.py @@ -113,20 +113,18 @@ class TestCase(object): self.description = description self.project = project - @staticmethod - def is_none(item): - return item is None or item == "" - def is_compatible(self, ci_installer, ci_scenario): try: - if not self.is_none(ci_installer): - if re.search(self.dependency.get_installer(), - ci_installer) is None: + if not ci_installer: + if self.dependency.get_installer(): return False - if not self.is_none(ci_scenario): - if re.search(self.dependency.get_scenario(), - ci_scenario) is None: + elif not re.search(self.dependency.get_installer(), ci_installer): + return False + if not ci_scenario: + if self.dependency.get_scenario(): return False + elif not re.search(self.dependency.get_scenario(), ci_scenario): + return False return True except TypeError: return False diff --git a/xtesting/tests/unit/ci/test_tier_handler.py b/xtesting/tests/unit/ci/test_tier_handler.py index d1900103..97ba5ab3 100644 --- a/xtesting/tests/unit/ci/test_tier_handler.py +++ b/xtesting/tests/unit/ci/test_tier_handler.py @@ -80,12 +80,6 @@ class TierHandlerTesting(unittest.TestCase): def test_get_ci_loop(self): self.assertEqual(self.tier.get_ci_loop(), 'test_ci_loop') - def test_testcase_is_none_in_item(self): - self.assertEqual(tier_handler.TestCase.is_none("item"), False) - - def test_testcase_is_none_no_item(self): - self.assertEqual(tier_handler.TestCase.is_none(None), True) - def test_testcase_is_compatible(self): self.assertEqual( self.testcase.is_compatible('test_installer', 'test_scenario'), @@ -106,6 +100,16 @@ class TierHandlerTesting(unittest.TestCase): False) args[0].assert_called_once_with('test_installer', 'test_installer') + def test_testcase_is_compatible_4(self): + self.assertEqual( + self.testcase.is_compatible(None, 'test_scenario'), False) + self.assertEqual( + self.testcase.is_compatible('', 'test_scenario'), False) + self.assertEqual( + self.testcase.is_compatible('test_installer', None), False) + self.assertEqual( + self.testcase.is_compatible('test_installer', ''), False) + def test_testcase_get_name(self): self.assertEqual(self.tier.get_name(), 'test_tier') -- cgit 1.2.3-korg