summaryrefslogtreecommitdiff
path: root/keystoneclient/tests
diff options
context:
space:
mode:
Diffstat (limited to 'keystoneclient/tests')
-rw-r--r--keystoneclient/tests/unit/test_base.py26
-rw-r--r--keystoneclient/tests/unit/v3/utils.py41
2 files changed, 7 insertions, 60 deletions
diff --git a/keystoneclient/tests/unit/test_base.py b/keystoneclient/tests/unit/test_base.py
index 7e1174e..38644c0 100644
--- a/keystoneclient/tests/unit/test_base.py
+++ b/keystoneclient/tests/unit/test_base.py
@@ -180,29 +180,3 @@ class ManagerTest(utils.TestCase):
management=True)
put_mock.assert_called_once_with(self.url, management=True, body=None)
self.assertEqual(rsrc.hi, 1)
-
-
-class TruncatedListTest(utils.TestCase):
- """Test that TruncatedList will not break existing checks
-
- A lot of code assumes that the value returned from list() is a python
- list, not an iterable object. Because of that, they perform various
- list-specific checks. This code should not be broken.
- """
-
- def test_eq(self):
- # flag `truncated` doesn't affect the check if it's False
- self.assertEqual([], base.TruncatedList([], truncated=False))
- self.assertEqual([1, 2, 3], base.TruncatedList([1, 2, 3],
- truncated=False))
-
- # flag `truncated` affects the check if it's True
- self.assertNotEqual([], base.TruncatedList([], truncated=True))
- self.assertNotEqual([1, 2, 3], base.TruncatedList([1, 2, 3],
- truncated=True))
-
- # flag `truncated` affects the equality check
- self.assertNotEqual(base.TruncatedList([], truncated=True),
- base.TruncatedList([], truncated=False))
- self.assertNotEqual(base.TruncatedList([1, 2, 3], truncated=True),
- base.TruncatedList([1, 2, 3], truncated=False))
diff --git a/keystoneclient/tests/unit/v3/utils.py b/keystoneclient/tests/unit/v3/utils.py
index 95a1dd6..bd1b970 100644
--- a/keystoneclient/tests/unit/v3/utils.py
+++ b/keystoneclient/tests/unit/v3/utils.py
@@ -192,16 +192,11 @@ class CrudTests(object):
kwargs.setdefault(uuid.uuid4().hex, uuid.uuid4().hex)
return kwargs
- def encode(self, entity, truncated=None):
- encoded = {}
- if truncated is not None:
- encoded['truncated'] = truncated
+ def encode(self, entity):
if isinstance(entity, dict):
- encoded[self.key] = entity
- return encoded
+ return {self.key: entity}
if isinstance(entity, list):
- encoded[self.collection_key] = entity
- return encoded
+ return {self.collection_key: entity}
raise NotImplementedError('Are you sure you want to encode that?')
def stub_entity(self, method, parts=None, entity=None, id=None, **kwargs):
@@ -292,22 +287,14 @@ class CrudTests(object):
self.assertRaises(TypeError, self.manager.list, **filter_kwargs)
- def _test_list(self, ref_list=None, expected_path=None,
- expected_query=None, truncated=None, **filter_kwargs):
+ def test_list(self, ref_list=None, expected_path=None,
+ expected_query=None, **filter_kwargs):
ref_list = ref_list or [self.new_ref(), self.new_ref()]
expected_path = self._get_expected_path(expected_path)
- # We want to catch all cases: when `truncated` is not returned by the
- # server, when it's False and when it's True.
- # Attribute `truncated` of the returned list-like object should exist
- # in all these cases. It should be False if the server returned a list
- # without the flag.
- expected_truncated = False
- if truncated:
- expected_truncated = truncated
-
self.requests_mock.get(urlparse.urljoin(self.TEST_URL, expected_path),
- json=self.encode(ref_list, truncated=truncated))
+ json=self.encode(ref_list))
+
returned_list = self.manager.list(**filter_kwargs)
self.assertEqual(len(ref_list), len(returned_list))
[self.assertIsInstance(r, self.model) for r in returned_list]
@@ -326,20 +313,6 @@ class CrudTests(object):
for key in qs_args:
self.assertIn(key, qs_args_expected)
- self.assertEqual(expected_truncated, returned_list.truncated)
-
- def test_list(self, ref_list=None, expected_path=None,
- expected_query=None, **filter_kwargs):
- # test simple list, without any truncation
- self._test_list(ref_list, expected_path, expected_query,
- **filter_kwargs)
- # test when a server returned a list with truncated=False
- self._test_list(ref_list, expected_path, expected_query,
- truncated=False, **filter_kwargs)
- # test when a server returned a list with truncated=True
- self._test_list(ref_list, expected_path, expected_query,
- truncated=True, **filter_kwargs)
-
def test_list_params(self):
ref_list = [self.new_ref()]
filter_kwargs = {uuid.uuid4().hex: uuid.uuid4().hex}