]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
Improving check_grants reliability 424/head
authorPragadeeswaran Sathyanarayanan <psathyan@redhat.com>
Tue, 28 Dec 2021 15:26:23 +0000 (20:56 +0530)
committerPragadeeswaran Sathyanarayanan <psathyan@redhat.com>
Mon, 10 Jan 2022 16:30:21 +0000 (22:00 +0530)
Signed-off-by: Pragadeeswaran Sathyanarayanan <psathyan@redhat.com>
s3tests_boto3/functional/test_s3.py

index 1e511a69e5a6ff8cccde41bcae6d6d38ca369fb9..6cd9911a7185886f41c6b721044de2f53e77974f 100644 (file)
@@ -4490,12 +4490,19 @@ def check_access_denied(fn, *args, **kwargs):
     status = _get_status(e.response)
     eq(status, 403)
 
+
 def check_grants(got, want):
     """
     Check that grants list in got matches the dictionaries in want,
     in any order.
     """
     eq(len(got), len(want))
+
+    # There are instances when got does not match due the order of item.
+    if got[0]["Grantee"].get("DisplayName"):
+        got.sort(key=lambda x: x["Grantee"].get("DisplayName"))
+        want.sort(key=lambda x: x["DisplayName"])
+
     for g, w in zip(got, want):
         w = dict(w)
         g = dict(g)
@@ -4507,6 +4514,7 @@ def check_grants(got, want):
         eq(g['Grantee'].pop('EmailAddress', None), w['EmailAddress'])
         eq(g, {'Grantee': {}})
 
+
 @attr(resource='bucket')
 @attr(method='get')
 @attr(operation='default acl')