Skip to content

Commit 96c8e41

Browse files
endpoint metrics test: ignore order (#12736)
* endpoint metrics test: ignore order * endpoint metrics test: ignore order
1 parent b7992db commit 96c8e41

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

unittests/test_metrics_queries.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,11 @@ def test_endpoint_queries(self, mock_now):
216216

217217
# Assert that we get expected querysets back. This is to be used to
218218
# support refactoring, in attempt of lowering the query count.
219-
self.assertSequenceEqual(
219+
220+
# https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertCountEqual
221+
# Test that sequence first contains the same elements as second, regardless of their order. When they don't, an error message listing the differences between the sequences will be generated.
222+
# Duplicate elements are not ignored when comparing first and second. It verifies whether each element has the same count in both sequences. Equivalent to: assertEqual(Counter(list(first)), Counter(list(second))) but works with sequences of unhashable objects as well.
223+
self.assertCountEqual(
220224
endpoint_queries["all"].values(),
221225
[
222226
{"id": 1, "date": date(2020, 7, 1), "last_modified": datetime(2020, 7, 1, 17, 45, 39, 791907, tzinfo=pytz.UTC), "mitigated": False, "mitigated_time": None, "mitigated_by_id": None, "false_positive": False, "out_of_scope": False, "risk_accepted": False, "endpoint_id": 2, "finding_id": 2, "endpoint__product__prod_type__member": False, "endpoint__product__member": True, "endpoint__product__prod_type__authorized_group": False, "endpoint__product__authorized_group": False},

0 commit comments

Comments
 (0)