Procházet zdrojové kódy

Fix iterating over client paged results in tests

Ehsan Chiniforooshan před 8 roky
rodič
revize
afbe03fc2b

+ 1 - 1
cloudbridge/cloud/providers/gce/resources.py

@@ -374,7 +374,7 @@ class GCEFirewallsDelegate(object):
         """
         if self._list_response is None:
             self._update_list_response()
-        for firewall in self._list_response.get('items', []):
+        for firewall in self._list_response:
             if ('targetTags' not in firewall or
                     len(firewall['targetTags']) != 1):
                 continue

+ 7 - 4
test/helpers/standard_interface_tests.py

@@ -37,10 +37,13 @@ def check_obj_properties(test, obj):
 def check_list(test, service, obj):
     list_objs = service.list()
     test.assertIsInstance(list_objs, ResultList)
-    all_records = list_objs
-    while list_objs.is_truncated:
-        list_objs = service.list(marker=list_objs.marker)
-        all_records += list_objs
+    if list_objs.supports_server_paging:
+        all_records = list_objs
+        while list_objs.is_truncated:
+            list_objs = service.list(marker=list_objs.marker)
+            all_records += list_objs
+    else:
+        all_records = list_objs.data
     match_objs = [o for o in all_records if o.id == obj.id]
     test.assertTrue(
         len(match_objs) == 1,