From 207dc61405e44040283da099239a76fe3b50e515 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Mon, 5 Jun 2017 08:56:35 -0700 Subject: [PATCH 1/5] Updating the assert tests for develop based on changes from 41569. --- tests/support/mixins.py | 62 +++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/tests/support/mixins.py b/tests/support/mixins.py index 804feb4196..77593e4718 100644 --- a/tests/support/mixins.py +++ b/tests/support/mixins.py @@ -514,9 +514,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): @@ -534,11 +535,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.assertTrue(self.__getWithinSaltReturn(ret, 'result')): + self.assertTrue(saltret) except AssertionError: log.info('Salt Full Return:\n{0}'.format(pprint.pformat(ret))) try: @@ -556,7 +559,8 @@ class SaltReturnAssertsMixin(object): def assertSaltFalseReturn(self, ret): try: - self.assertFalse(self.__getWithinSaltReturn(ret, 'result')) + for saltret in self.assertFalse(self.__getWithinSaltReturn(ret, 'result')): + self.assertFalse(saltret) except AssertionError: log.info('Salt Full Return:\n{0}'.format(pprint.pformat(ret))) try: @@ -572,7 +576,8 @@ class SaltReturnAssertsMixin(object): def assertSaltNoneReturn(self, ret): try: - self.assertIsNone(self.__getWithinSaltReturn(ret, 'result')) + for saltret in self.assertIsNone(self.__getWithinSaltReturn(ret, 'result')): + self.assertIsNone(saltret) except AssertionError: log.info('Salt Full Return:\n{0}'.format(pprint.pformat(ret))) try: @@ -587,54 +592,45 @@ 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.assetIn(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.assetNotIn(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.assetIn(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.assetNotIn(item_to_check, saltret) def assertInSaltReturnRegexpMatches(self, ret, pattern, keys=()): - return self.assertRegex( - 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) class SaltMinionEventAssertsMixin(object): From e39d05060e4c8912b9117f18a437a55e77a9ae84 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Thu, 8 Jun 2017 14:17:35 -0700 Subject: [PATCH 2/5] Fixing typo in assertSaltTrueReturn, assertSaltFalseReturn and assertSaltNoneReturn. --- tests/support/mixins.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/support/mixins.py b/tests/support/mixins.py index 77593e4718..9af4ca657f 100644 --- a/tests/support/mixins.py +++ b/tests/support/mixins.py @@ -540,7 +540,7 @@ class SaltReturnAssertsMixin(object): def assertSaltTrueReturn(self, ret): try: - for saltret in 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))) @@ -559,7 +559,7 @@ class SaltReturnAssertsMixin(object): def assertSaltFalseReturn(self, ret): try: - for saltret in 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))) @@ -576,7 +576,7 @@ class SaltReturnAssertsMixin(object): def assertSaltNoneReturn(self, ret): try: - for saltret in 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))) From ace175edae917f3fec9eab96dc7a771f6ef25de8 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Thu, 8 Jun 2017 15:30:44 -0700 Subject: [PATCH 3/5] Couple more typos, assert not asset. --- tests/support/mixins.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/support/mixins.py b/tests/support/mixins.py index 9af4ca657f..a1d942b014 100644 --- a/tests/support/mixins.py +++ b/tests/support/mixins.py @@ -604,19 +604,19 @@ class SaltReturnAssertsMixin(object): def assertInSaltStateWarning(self, in_comment, ret): for saltret in self.__getWithinSaltReturn(ret, 'warnings'): - self.assetIn(in_comment, saltret) + self.assertIn(in_comment, saltret) def assertNotInSaltStateWarning(self, not_in_comment, ret): for saltret in self.__getWithinSaltReturn(ret, 'warnings'): - self.assetNotIn(not_in_comment, saltret) + self.assertNotIn(not_in_comment, saltret) def assertInSaltReturn(self, item_to_check, ret, keys): for saltret in self.__getWithinSaltReturn(ret, keys): - self.assetIn(item_to_check, saltret) + self.assertIn(item_to_check, saltret) def assertNotInSaltReturn(self, item_to_check, ret, keys): for saltret in self.__getWithinSaltReturn(ret, keys): - self.assetNotIn(item_to_check, saltret) + self.assertNotIn(item_to_check, saltret) def assertInSaltReturnRegexpMatches(self, ret, pattern, keys=()): for saltret in self.__getWithinSaltReturn(ret, keys): From 17ddc9396c95859b71ab34bb9cfb5bcd38e0d1fd Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Thu, 8 Jun 2017 20:03:05 -0700 Subject: [PATCH 4/5] Fixing the last text failure. --- tests/integration/files/pillar/base/top.sls | 1 + tests/support/mixins.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/files/pillar/base/top.sls b/tests/integration/files/pillar/base/top.sls index b67e132485..18a4219d08 100644 --- a/tests/integration/files/pillar/base/top.sls +++ b/tests/integration/files/pillar/base/top.sls @@ -2,6 +2,7 @@ base: 'minion': - generic - blackout + - gpg 'sub_minion': - generic - blackout diff --git a/tests/support/mixins.py b/tests/support/mixins.py index a1d942b014..38601d81ff 100644 --- a/tests/support/mixins.py +++ b/tests/support/mixins.py @@ -620,7 +620,7 @@ class SaltReturnAssertsMixin(object): def assertInSaltReturnRegexpMatches(self, ret, pattern, keys=()): for saltret in self.__getWithinSaltReturn(ret, keys): - self.assertRegexpMatches(saltret, pattern) + self.assertRegex(saltret, pattern) def assertSaltStateChangesEqual(self, ret, comparison, keys=()): keys = ['changes'] + self.__return_valid_keys(keys) From 008642478789f5c71b9e5ca5b5eec5bd2084d7ff Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Thu, 8 Jun 2017 20:06:29 -0700 Subject: [PATCH 5/5] Removing rogue file that shouldn't be referenced --- tests/integration/files/pillar/base/top.sls | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/files/pillar/base/top.sls b/tests/integration/files/pillar/base/top.sls index 18a4219d08..b67e132485 100644 --- a/tests/integration/files/pillar/base/top.sls +++ b/tests/integration/files/pillar/base/top.sls @@ -2,7 +2,6 @@ base: 'minion': - generic - blackout - - gpg 'sub_minion': - generic - blackout