def check_permissions(key, expected_perms):
    grants = self.s3_client.get_object_acl(Bucket=bucket_name, Key=key)['Grants']
    grants = [g for g in grants if ('AllUsers' in g.get('Grantee', {}).get('URI', ''))]
    self.assertEquals(len(grants), 1)
    permissions = grants[0]['Permission']
    permissions = (permissions if isinstance(permissions, list) else [permissions])
    self.assertEquals(len(permissions), expected_perms)
def check_permissions(key, expected_perms):
    grants = self.s3_client.get_object_acl(Bucket=bucket_name, Key=key)['Grants']
    grants = [g for g in grants if ('AllUsers' in g.get('Grantee', {}).get('URI', ))]
    self.assertEquals(len(grants), 1)
    permissions = grants[0]['Permission']
    permissions = (permissions if isinstance(permissions, list) else [permissions])
    self.assertEquals(len(permissions), expected_perms)