Skip to content

Commit 36f5d58

Browse files
committed
commenting expect_list test method
Signed-off-by: Andrew Twydell <[email protected]>
1 parent 074051c commit 36f5d58

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tests/unit/helpers/cmci_helper.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,14 @@ def run(self, module, config):
123123
assert isinstance(self.expected, dict)
124124
assert isinstance(result, dict)
125125

126+
# when a list of items is expected but the order varies, this block intecepts the actual result and sorts
127+
# the list, allowing the expected and actual output to be compared in the same order
126128
if self.expected_list:
127-
# get list of items from a string in the result dict - comma separated text between 2 points in string
128129
actual_list = result.get(self.string_containing_list)[self.chars_before_list:-self.chars_after_list].split(", ")
129-
# sort alphabetically
130130
actual_list.sort()
131-
# get the text before the list in the string
132131
before_list = result.get(self.string_containing_list)[:self.chars_before_list]
133-
# get the text after the list in the string
134132
after_list = result.get(self.string_containing_list)[-self.chars_after_list:]
135-
# put the text before and after the list together with the newly ordered list
136133
concat = before_list + ", ".join(actual_list) + after_list
137-
# update the result dict to use the string with the ordered list of items
138134
result.update({self.string_containing_list: concat})
139135

140136
if self.expected != result:

tests/unit/modules/test_cmci_filters.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,10 @@ def test_extra_attributes_root(cmci_module):
640640
if sys.version_info.major <= 2:
641641
extension = "pyc"
642642

643+
# Order that Ansible returns supported parameters is not consistent everytime
644+
# expect_list ensures expected and actual output are compared after sorting the
645+
# list first. This means passing tests if all expected attributes are listed, but not caring about
646+
# the order.
643647
before_list = "Unsupported parameters for (basic.%s) module: resources.complex_filter.orange. Supported parameters include: " % extension
644648
sorted_list = ["cmci_cert", "cmci_host", "cmci_key", "cmci_password",
645649
"cmci_port", "cmci_user", "context", "fail_on_nodata", "insecure",

0 commit comments

Comments
 (0)