From e2a4d5e1e28bf3f904b8ac16dda763b02c7a3adf Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Fri, 2 Jun 2017 15:02:46 -0600 Subject: [PATCH 1/2] Check all entries in result Without this change, we ony check the first return from state tests, if there is more than one state run, we do not check subsequent tests. --- tests/integration/__init__.py | 62 ++++++++++++++++------------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index 5041070aa5..5604eaa41a 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -2126,9 +2126,10 @@ class SaltReturnAssertsMixIn(object): def __getWithinSaltReturn(self, ret, keys): self.assertReturnNonEmptySaltType(ret) - keys = self.__return_valid_keys(keys) - okeys = keys[:] + ret_data = [] for part in six.itervalues(ret): + keys = self.__return_valid_keys(keys) + okeys = keys[:] try: ret_item = part[okeys.pop(0)] except (KeyError, TypeError): @@ -2146,11 +2147,13 @@ class SaltReturnAssertsMixIn(object): ''.join(['[\'{0}\']'.format(k) for k in keys]), part ) ) - return ret_item + ret_data.append(ret_item) + return ret_data def assertSaltTrueReturn(self, ret): try: - self.assertTrue(self.__getWithinSaltReturn(ret, 'result')) + for saltret in self.__getWithinSaltReturn(ret, 'result'): + self.assertTrue(saltret) except AssertionError: log.info('Salt Full Return:\n{0}'.format(pprint.pformat(ret))) try: @@ -2168,7 +2171,8 @@ class SaltReturnAssertsMixIn(object): def assertSaltFalseReturn(self, ret): try: - self.assertFalse(self.__getWithinSaltReturn(ret, 'result')) + for saltret in self.__getWithinSaltReturn(ret, 'result'): + self.assertFalse(saltret) except AssertionError: log.info('Salt Full Return:\n{0}'.format(pprint.pformat(ret))) try: @@ -2184,7 +2188,8 @@ class SaltReturnAssertsMixIn(object): def assertSaltNoneReturn(self, ret): try: - self.assertIsNone(self.__getWithinSaltReturn(ret, 'result')) + for saltret in self.__getWithinSaltReturn(ret, 'result'): + self.assertIsNone(saltret) except AssertionError: log.info('Salt Full Return:\n{0}'.format(pprint.pformat(ret))) try: @@ -2199,51 +2204,42 @@ class SaltReturnAssertsMixIn(object): ) def assertInSaltComment(self, in_comment, ret): - return self.assertIn( - in_comment, self.__getWithinSaltReturn(ret, 'comment') - ) + for saltret in self.__getWithinSaltReturn(ret, 'comment'): + self.assertIn(in_comment, saltret) def assertNotInSaltComment(self, not_in_comment, ret): - return self.assertNotIn( - not_in_comment, self.__getWithinSaltReturn(ret, 'comment') - ) + for saltret in self.__getWithinSaltReturn(ret, 'comment'): + self.assertNotIn(not_in_comment, saltret) def assertSaltCommentRegexpMatches(self, ret, pattern): return self.assertInSaltReturnRegexpMatches(ret, pattern, 'comment') def assertInSaltStateWarning(self, in_comment, ret): - return self.assertIn( - in_comment, self.__getWithinSaltReturn(ret, 'warnings') - ) + for saltret in self.__getWithinSaltReturn(ret, 'warnings'): + self.assertIn(in_comment, saltret) def assertNotInSaltStateWarning(self, not_in_comment, ret): - return self.assertNotIn( - not_in_comment, self.__getWithinSaltReturn(ret, 'warnings') - ) + for saltret in self.__getWithinSaltReturn(ret, 'warnings'): + self.assertNotIn(not_in_comment, saltret) def assertInSaltReturn(self, item_to_check, ret, keys): - return self.assertIn( - item_to_check, self.__getWithinSaltReturn(ret, keys) - ) + for saltret in self.__getWithinSaltReturn(ret, keys): + self.assertIn(item_to_check, saltret) def assertNotInSaltReturn(self, item_to_check, ret, keys): - return self.assertNotIn( - item_to_check, self.__getWithinSaltReturn(ret, keys) - ) + for saltret in self.__getWithinSaltReturn(ret, keys): + self.assertNotIn(item_to_check, saltret) def assertInSaltReturnRegexpMatches(self, ret, pattern, keys=()): - return self.assertRegexpMatches( - self.__getWithinSaltReturn(ret, keys), pattern - ) + for saltret in self.__getWithinSaltReturn(ret, keys): + self.assertRegexpMatches(saltret, pattern) def assertSaltStateChangesEqual(self, ret, comparison, keys=()): keys = ['changes'] + self.__return_valid_keys(keys) - return self.assertEqual( - self.__getWithinSaltReturn(ret, keys), comparison - ) + for saltret in self.__getWithinSaltReturn(ret, keys): + self.assertEqual(saltret, comparison) def assertSaltStateChangesNotEqual(self, ret, comparison, keys=()): keys = ['changes'] + self.__return_valid_keys(keys) - return self.assertNotEqual( - self.__getWithinSaltReturn(ret, keys), comparison - ) + for saltret in self.__getWithinSaltReturn(ret, keys): + self.assertNotEqual(saltret, comparison) From 19ea5481b6d4702c95c0bd3bc31345809d4e1d74 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Mon, 5 Jun 2017 17:45:23 -0600 Subject: [PATCH 2/2] remove test that never passed --- tests/integration/modules/state.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/integration/modules/state.py b/tests/integration/modules/state.py index cd40d9d9a9..427ce228b4 100644 --- a/tests/integration/modules/state.py +++ b/tests/integration/modules/state.py @@ -695,13 +695,6 @@ class StateModuleTest(integration.ModuleCase, #ret = self.run_function('state.sls', mods='requisites.fullsls_prereq') #self.assertEqual(['sls command can only be used with require requisite'], ret) - def test_requisites_full_sls_import(self): - ''' - Test full sls requisite with nothing but an import - ''' - ret = self.run_function('state.sls', mods='requisites.fullsls_require_import') - self.assertSaltTrueReturn(ret) - def test_requisites_prereq_simple_ordering_and_errors(self): ''' Call sls file containing several prereq_in and prereq.