Explorar el Código

Improved iteration testing and forced to occur during tests

Nuwan Goonasekera hace 8 años
padre
commit
053ed6731f
Se han modificado 2 ficheros con 13 adiciones y 5 borrados
  1. 2 1
      test/helpers/__init__.py
  2. 11 4
      test/helpers/standard_interface_tests.py

+ 2 - 1
test/helpers/__init__.py

@@ -194,7 +194,8 @@ class ProviderTestBase(unittest.TestCase):
         provider_class = factory.get_provider_class(provider_name,
                                                     get_mock=use_mock_drivers)
         config = {'default_wait_interval':
-                  self.get_provider_wait_interval(provider_class)}
+                  self.get_provider_wait_interval(provider_class),
+                  'default_result_limit': 1}
         return provider_class(config)
 
     @property

+ 11 - 4
test/helpers/standard_interface_tests.py

@@ -5,6 +5,7 @@ This includes:
    2. Checking for object equality and repr
    3. Checking standard behaviour for list, iter, find, get, delete
 """
+from cloudbridge.cloud.interfaces.resources import ResultList
 
 
 def check_repr(test, obj):
@@ -16,12 +17,18 @@ def check_repr(test, obj):
 
 
 def check_list(test, service, obj):
-    list_objs = [o for o in service.list() if o.id == obj.id]
+    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
+    match_objs = [o for o in all_records if o.id == obj.id]
     test.assertTrue(
-        len(list_objs) == 1,
+        len(match_objs) == 1,
         "List objects for %s does not return the expected object id %s. Got %s"
-        % (type(obj).__name__, obj.id, list_objs))
-    return list_objs
+        % (type(obj).__name__, obj.id, match_objs))
+    return match_objs
 
 
 def check_iter(test, service, obj):