summaryrefslogtreecommitdiff
path: root/openstackclient/tests/fakes.py
diff options
context:
space:
mode:
authorlin-hua-cheng <os.lcheng@gmail.com>2015-11-25 00:17:49 -0800
committerlin-hua-cheng <os.lcheng@gmail.com>2015-11-25 00:17:49 -0800
commitb3c2668c341da42ce7f193b1035f7ab352538d95 (patch)
tree0afb4fd597292ecfb0a92be06e396b79529f2c53 /openstackclient/tests/fakes.py
parentc0676fe17f10310041964fa1008fe966f5efbe91 (diff)
downloadpython-openstackclient-b3c2668c341da42ce7f193b1035f7ab352538d95.tar.gz
Move FakeServer to tests.common.v2.compute.fakes
FakeServer should not be in tests.fakes since this should be just for generic re-usable classes. Change-Id: I19209952de69626dfa3caadc5d1cc69b7feadeba
Diffstat (limited to 'openstackclient/tests/fakes.py')
-rw-r--r--openstackclient/tests/fakes.py70
1 files changed, 0 insertions, 70 deletions
diff --git a/openstackclient/tests/fakes.py b/openstackclient/tests/fakes.py
index 85e65fb1..9f4dcc50 100644
--- a/openstackclient/tests/fakes.py
+++ b/openstackclient/tests/fakes.py
@@ -13,12 +13,10 @@
# under the License.
#
-import copy
import json
import mock
import six
import sys
-import uuid
from keystoneauth1 import fixture
import requests
@@ -185,71 +183,3 @@ class FakeModel(dict):
return self[key]
except KeyError:
raise AttributeError(key)
-
-
-class FakeServer(object):
- """Fake one or more compute servers."""
-
- @staticmethod
- def create_one_server(attrs={}, methods={}):
- """Create a fake server.
-
- :param Dictionary attrs:
- A dictionary with all attributes
- :param Dictionary methods:
- A dictionary with all methods
- :return:
- A FakeResource object, with id, name, metadata
- """
- # Set default attributes.
- server_info = {
- 'id': 'server-id-' + uuid.uuid4().hex,
- 'name': 'server-name-' + uuid.uuid4().hex,
- 'metadata': {},
- }
-
- # Overwrite default attributes.
- server_info.update(attrs)
-
- server = FakeResource(info=copy.deepcopy(server_info),
- methods=methods,
- loaded=True)
- return server
-
- @staticmethod
- def create_servers(attrs={}, methods={}, count=2):
- """Create multiple fake servers.
-
- :param Dictionary attrs:
- A dictionary with all attributes
- :param Dictionary methods:
- A dictionary with all methods
- :param int count:
- The number of servers to fake
- :return:
- A list of FakeResource objects faking the servers
- """
- servers = []
- for i in range(0, count):
- servers.append(FakeServer.create_one_server(attrs, methods))
-
- return servers
-
- @staticmethod
- def get_servers(servers=None, count=2):
- """Get an iterable MagicMock object with a list of faked servers.
-
- If servers list is provided, then initialize the Mock object with the
- list. Otherwise create one.
-
- :param List servers:
- A list of FakeResource objects faking servers
- :param int count:
- The number of servers to fake
- :return:
- An iterable Mock object with side_effect set to a list of faked
- servers
- """
- if servers is None:
- servers = FakeServer.create_servers(count)
- return mock.MagicMock(side_effect=servers)