diff options
author | Corey Bryant <corey.bryant@canonical.com> | 2015-06-24 15:55:50 -0400 |
---|---|---|
committer | Corey Bryant <corey.bryant@canonical.com> | 2015-06-29 10:22:13 -0400 |
commit | 1b93adc8fb27a50de7ab4367f41573e07b28d9ac (patch) | |
tree | ec6bd65c1bbbc21a6e650fb6a64ed3f62404911e | |
parent | cc38f51086b930a05c0abecf6c9e00fdf5c294f6 (diff) | |
download | python-glanceclient-1b93adc8fb27a50de7ab4367f41573e07b28d9ac.tar.gz |
Account for dictionary order in test_shell.py
Change-Id: Id15f3d642e8fcbd663f12b32f52b6014e32574a5
Closes-Bug: 1468485
-rw-r--r-- | glanceclient/tests/unit/test_shell.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/glanceclient/tests/unit/test_shell.py b/glanceclient/tests/unit/test_shell.py index d6ce9e6..c3d258d 100644 --- a/glanceclient/tests/unit/test_shell.py +++ b/glanceclient/tests/unit/test_shell.py @@ -15,6 +15,10 @@ # under the License. import argparse +try: + from collections import OrderedDict +except ImportError: + from ordereddict import OrderedDict import os import sys import uuid @@ -494,7 +498,8 @@ class ShellCacheSchemaTest(testutils.TestCase): } self.client = mock.Mock() - self.client.schemas.get.return_value = schemas.Schema(self.schema_dict) + schema_odict = OrderedDict(self.schema_dict) + self.client.schemas.get.return_value = schemas.Schema(schema_odict) def _mock_shell_setup(self): mocked_get_client = mock.MagicMock(return_value=self.client) @@ -514,6 +519,7 @@ class ShellCacheSchemaTest(testutils.TestCase): options = { 'get_schema': True } + schema_odict = OrderedDict(self.schema_dict) self.shell._cache_schemas(self._make_args(options), home_dir=self.cache_dir) @@ -523,9 +529,9 @@ class ShellCacheSchemaTest(testutils.TestCase): open.mock_calls[0]) self.assertEqual(mock.call(self.cache_files[1], 'w'), open.mock_calls[4]) - self.assertEqual(mock.call().write(json.dumps(self.schema_dict)), + self.assertEqual(mock.call().write(json.dumps(schema_odict)), open.mock_calls[2]) - self.assertEqual(mock.call().write(json.dumps(self.schema_dict)), + self.assertEqual(mock.call().write(json.dumps(schema_odict)), open.mock_calls[6]) @mock.patch('six.moves.builtins.open', new=mock.mock_open(), create=True) @@ -534,6 +540,7 @@ class ShellCacheSchemaTest(testutils.TestCase): options = { 'get_schema': False } + schema_odict = OrderedDict(self.schema_dict) self.shell._cache_schemas(self._make_args(options), home_dir=self.cache_dir) @@ -543,9 +550,9 @@ class ShellCacheSchemaTest(testutils.TestCase): open.mock_calls[0]) self.assertEqual(mock.call(self.cache_files[1], 'w'), open.mock_calls[4]) - self.assertEqual(mock.call().write(json.dumps(self.schema_dict)), + self.assertEqual(mock.call().write(json.dumps(schema_odict)), open.mock_calls[2]) - self.assertEqual(mock.call().write(json.dumps(self.schema_dict)), + self.assertEqual(mock.call().write(json.dumps(schema_odict)), open.mock_calls[6]) @mock.patch('six.moves.builtins.open', new=mock.mock_open(), create=True) |