gcloud 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +2 -3
- data/CHANGELOG +4 -0
- data/LICENSE +674 -0
- data/Manifest +111 -0
- data/README.md +4 -3
- data/bin/gcutil +53 -0
- data/gcloud.gemspec +4 -3
- data/packages/gcutil-1.7.1/CHANGELOG +197 -0
- data/packages/gcutil-1.7.1/LICENSE +202 -0
- data/packages/gcutil-1.7.1/VERSION +1 -0
- data/packages/gcutil-1.7.1/gcutil +53 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/LICENSE +23 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/__init__.py +1 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/discovery.py +743 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/errors.py +123 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/ext/__init__.py +0 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/http.py +1443 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/mimeparse.py +172 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/model.py +385 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/apiclient/schema.py +303 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/oauth2client/__init__.py +1 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/oauth2client/anyjson.py +32 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/oauth2client/appengine.py +528 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/oauth2client/client.py +1139 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/oauth2client/clientsecrets.py +105 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/oauth2client/crypt.py +244 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/oauth2client/django_orm.py +124 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/oauth2client/file.py +107 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/oauth2client/locked_file.py +343 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/oauth2client/multistore_file.py +379 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/oauth2client/tools.py +174 -0
- data/packages/gcutil-1.7.1/lib/google_api_python_client/uritemplate/__init__.py +147 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/LICENSE +202 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/__init__.py +3 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/__init__.py +3 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.py +356 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/appcommands.py +783 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/basetest.py +1260 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/datelib.py +421 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/debug.py +60 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/file_util.py +181 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/resources.py +67 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/run_script_module.py +217 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/setup_command.py +159 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/shellutil.py +49 -0
- data/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/stopwatch.py +204 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/__init__.py +0 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/auth_helper.py +140 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/auth_helper_test.py +149 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/auto_auth.py +130 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/auto_auth_test.py +75 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/basic_cmds.py +128 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/basic_cmds_test.py +111 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/command_base.py +1808 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/command_base_test.py +1651 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/compute/v1beta13.json +2851 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/compute/v1beta14.json +3361 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/disk_cmds.py +342 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/disk_cmds_test.py +474 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/firewall_cmds.py +344 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/firewall_cmds_test.py +231 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/flags_cache.py +274 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/gcutil +89 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/gcutil_logging.py +69 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/image_cmds.py +262 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/image_cmds_test.py +172 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/instance_cmds.py +1506 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/instance_cmds_test.py +1904 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/kernel_cmds.py +91 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/kernel_cmds_test.py +56 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/machine_type_cmds.py +106 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/machine_type_cmds_test.py +59 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/metadata.py +96 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/metadata_lib.py +357 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/metadata_test.py +84 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/mock_api.py +420 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/mock_metadata.py +58 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/move_cmds.py +824 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/move_cmds_test.py +307 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/network_cmds.py +178 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/network_cmds_test.py +133 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/operation_cmds.py +181 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/operation_cmds_test.py +196 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/path_initializer.py +38 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/project_cmds.py +173 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/project_cmds_test.py +111 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/scopes.py +61 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/scopes_test.py +50 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.py +276 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds_test.py +260 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/ssh_keys.py +266 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/ssh_keys_test.py +128 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/table_formatter.py +563 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/thread_pool.py +188 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/thread_pool_test.py +88 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/utils.py +208 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/utils_test.py +193 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/version.py +17 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/version_checker.py +246 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/version_checker_test.py +271 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/zone_cmds.py +151 -0
- data/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/zone_cmds_test.py +60 -0
- data/packages/gcutil-1.7.1/lib/httplib2/LICENSE +21 -0
- data/packages/gcutil-1.7.1/lib/httplib2/httplib2/__init__.py +1630 -0
- data/packages/gcutil-1.7.1/lib/httplib2/httplib2/cacerts.txt +714 -0
- data/packages/gcutil-1.7.1/lib/httplib2/httplib2/iri2uri.py +110 -0
- data/packages/gcutil-1.7.1/lib/httplib2/httplib2/socks.py +438 -0
- data/packages/gcutil-1.7.1/lib/iso8601/LICENSE +20 -0
- data/packages/gcutil-1.7.1/lib/iso8601/iso8601/__init__.py +1 -0
- data/packages/gcutil-1.7.1/lib/iso8601/iso8601/iso8601.py +102 -0
- data/packages/gcutil-1.7.1/lib/iso8601/iso8601/test_iso8601.py +111 -0
- data/packages/gcutil-1.7.1/lib/python_gflags/AUTHORS +2 -0
- data/packages/gcutil-1.7.1/lib/python_gflags/LICENSE +28 -0
- data/packages/gcutil-1.7.1/lib/python_gflags/gflags.py +2862 -0
- data/packages/gcutil-1.7.1/lib/python_gflags/gflags2man.py +544 -0
- data/packages/gcutil-1.7.1/lib/python_gflags/gflags_validators.py +187 -0
- metadata +118 -5
- metadata.gz.sig +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/python
|
|
2
|
+
#
|
|
3
|
+
# Copyright 2012 Google Inc. All Rights Reserved.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
"""Unit tests for the metadata package."""
|
|
18
|
+
|
|
19
|
+
from __future__ import with_statement
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
import path_initializer
|
|
24
|
+
path_initializer.InitializeSysPath()
|
|
25
|
+
|
|
26
|
+
import copy
|
|
27
|
+
import tempfile
|
|
28
|
+
|
|
29
|
+
from google.apputils import app
|
|
30
|
+
import gflags as flags
|
|
31
|
+
import unittest
|
|
32
|
+
|
|
33
|
+
from gcutil import metadata
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
FLAGS = flags.FLAGS
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class MetadataTest(unittest.TestCase):
|
|
40
|
+
|
|
41
|
+
def testGatherMetadata(self):
|
|
42
|
+
flag_values = copy.deepcopy(FLAGS)
|
|
43
|
+
metadata_flags_processor = metadata.MetadataFlagsProcessor(flag_values)
|
|
44
|
+
|
|
45
|
+
with tempfile.NamedTemporaryFile() as metadata_file:
|
|
46
|
+
metadata_file.write('metadata file content')
|
|
47
|
+
metadata_file.flush()
|
|
48
|
+
|
|
49
|
+
flag_values.metadata = ['bar:baz']
|
|
50
|
+
flag_values.metadata_from_file = ['bar_file:%s' % metadata_file.name]
|
|
51
|
+
|
|
52
|
+
metadata_entries = metadata_flags_processor.GatherMetadata()
|
|
53
|
+
|
|
54
|
+
self.assertEqual(len(metadata_entries), 2)
|
|
55
|
+
self.assertEqual(metadata_entries[0]['key'], 'bar')
|
|
56
|
+
self.assertEqual(metadata_entries[0]['value'], 'baz')
|
|
57
|
+
self.assertEqual(metadata_entries[1]['key'], 'bar_file')
|
|
58
|
+
self.assertEqual(metadata_entries[1]['value'],
|
|
59
|
+
'metadata file content')
|
|
60
|
+
|
|
61
|
+
def testGatherMetadataWithDuplicateKeys(self):
|
|
62
|
+
flag_values = copy.deepcopy(FLAGS)
|
|
63
|
+
metadata_flags_processor = metadata.MetadataFlagsProcessor(flag_values)
|
|
64
|
+
|
|
65
|
+
flag_values.metadata = ['bar:baz', 'bar:foo']
|
|
66
|
+
self.assertRaises(app.UsageError, metadata_flags_processor.GatherMetadata)
|
|
67
|
+
|
|
68
|
+
flag_values.metadata = ['bar:baz', 'bar:foo', 'foo:baz', 'foobar:val']
|
|
69
|
+
self.assertRaises(app.UsageError, metadata_flags_processor.GatherMetadata)
|
|
70
|
+
|
|
71
|
+
flag_values.metadata = ['foo:foo', 'bar:baz', 'bar:foo', 'foo:baz',
|
|
72
|
+
'foobar:val']
|
|
73
|
+
self.assertRaises(app.UsageError, metadata_flags_processor.GatherMetadata)
|
|
74
|
+
|
|
75
|
+
with tempfile.NamedTemporaryFile() as metadata_file:
|
|
76
|
+
metadata_file.write('metadata file content')
|
|
77
|
+
metadata_file.flush()
|
|
78
|
+
flag_values.metadata = ['bar:baz']
|
|
79
|
+
flag_values.metadata_from_file = ['bar:%s' % metadata_file.name]
|
|
80
|
+
self.assertRaises(app.UsageError, metadata_flags_processor.GatherMetadata)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if __name__ == '__main__':
|
|
84
|
+
unittest.main()
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
# Copyright 2012 Google Inc. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Mock Google Compute Engine API used for unit tests."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
import inspect
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class CommandExecutor(object):
|
|
25
|
+
"""An object to represent an apiclient endpoint with a fixed response."""
|
|
26
|
+
|
|
27
|
+
def __init__(self, response):
|
|
28
|
+
"""Create a new CommandExecutor to return response for each API call."""
|
|
29
|
+
self._response = response
|
|
30
|
+
|
|
31
|
+
def __call__(self, **unused_kw):
|
|
32
|
+
"""Handle calling this object (part 1 of making an apiclient call)."""
|
|
33
|
+
self._parameters = unused_kw
|
|
34
|
+
return self
|
|
35
|
+
|
|
36
|
+
def execute(self):
|
|
37
|
+
"""Return the stored results for this API call (part 2 of apiclient)."""
|
|
38
|
+
return self._response
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class MockRequest(object):
|
|
42
|
+
"""Mock request type for use with the MockApi class."""
|
|
43
|
+
|
|
44
|
+
def __init__(self, payload, method_name=None):
|
|
45
|
+
self.request_payload = payload
|
|
46
|
+
# For now we return the request as a response.
|
|
47
|
+
self.result_payload = payload
|
|
48
|
+
self.method_name = method_name
|
|
49
|
+
|
|
50
|
+
def execute(self, http=None): # pylint: disable-msg=W0613
|
|
51
|
+
return self.result_payload
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class MockApiBase(object):
|
|
55
|
+
"""Base class for all mock APIs."""
|
|
56
|
+
|
|
57
|
+
def __init__(self):
|
|
58
|
+
self.requests = []
|
|
59
|
+
|
|
60
|
+
def RegisterRequest(self, request_data, **kwargs):
|
|
61
|
+
if kwargs:
|
|
62
|
+
request_data = dict(request_data.items() + kwargs.items())
|
|
63
|
+
request = MockRequest(request_data, inspect.stack()[1][3])
|
|
64
|
+
self.requests.append(request)
|
|
65
|
+
return request
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class MockDisksApi(MockApiBase):
|
|
69
|
+
"""Mock return result of the MockApi.disks() method."""
|
|
70
|
+
|
|
71
|
+
def get(self, project='wrong_project', disk='wrong_disk', **kwargs):
|
|
72
|
+
return self.RegisterRequest({'project': project, 'disk': disk}, **kwargs)
|
|
73
|
+
|
|
74
|
+
def insert(self, project='wrong_project', body='wrong_disk_resource',
|
|
75
|
+
sourceImage='wrong_source_image', **kwargs):
|
|
76
|
+
return self.RegisterRequest({'project': project, 'body': body,
|
|
77
|
+
'sourceImage': sourceImage}, **kwargs)
|
|
78
|
+
|
|
79
|
+
def delete(self, project='wrong_project', disk='wrong_disk', **kwargs):
|
|
80
|
+
return self.RegisterRequest({'project': project, 'disk': disk}, **kwargs)
|
|
81
|
+
|
|
82
|
+
def list(self, project='wrong_project', zone='wrong_zone', **kwargs):
|
|
83
|
+
return self.RegisterRequest({'project': project, 'zone': zone}, **kwargs)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class MockFirewallsApi(MockApiBase):
|
|
87
|
+
"""Mock return result of the MockApi.firewalls() method."""
|
|
88
|
+
|
|
89
|
+
def get(self, project='wrong_project', firewall='wrong_firewall'):
|
|
90
|
+
return self.RegisterRequest({'project': project, 'firewall': firewall})
|
|
91
|
+
|
|
92
|
+
def insert(self, project='wrong_project', body='wrong_firewall_resource'):
|
|
93
|
+
return self.RegisterRequest({'project': project, 'body': body})
|
|
94
|
+
|
|
95
|
+
def delete(self, project='wrong_project', firewall='wrong_firewall'):
|
|
96
|
+
return self.RegisterRequest({'project': project, 'firewall': firewall})
|
|
97
|
+
|
|
98
|
+
def list(self, project='wrong_project'):
|
|
99
|
+
return self.RegisterRequest({'project': project})
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class MockBackendGroupsApi(MockApiBase):
|
|
103
|
+
"""Mock return result of the MockApi.backendGroups() method."""
|
|
104
|
+
|
|
105
|
+
def get(self, project='wrong_project', backendGroup='wrong_backend_group',
|
|
106
|
+
**kwargs):
|
|
107
|
+
return self.RegisterRequest({'project': project,
|
|
108
|
+
'backendGroup': backendGroup}, **kwargs)
|
|
109
|
+
|
|
110
|
+
def insert(self, project='wrong_project',
|
|
111
|
+
body='wrong_backend_group_resource', **kwargs):
|
|
112
|
+
return self.RegisterRequest({'project': project, 'body': body}, **kwargs)
|
|
113
|
+
|
|
114
|
+
def delete(self, project='wrong_project', backendGroup='wrong_backend_group',
|
|
115
|
+
**kwargs):
|
|
116
|
+
return self.RegisterRequest({'project': project,
|
|
117
|
+
'backendGroup': backendGroup}, **kwargs)
|
|
118
|
+
|
|
119
|
+
def list(self, project='wrong_project', **kwargs):
|
|
120
|
+
return self.RegisterRequest({'project': project}, **kwargs)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class MockPublicEndpointsApi(MockApiBase):
|
|
124
|
+
"""Mock return result of the MockApi.publicEndpoints() method."""
|
|
125
|
+
|
|
126
|
+
def get(self, project='wrong_project',
|
|
127
|
+
publicEndpoint='wrong_public_endpoint'):
|
|
128
|
+
return self.RegisterRequest({'project': project,
|
|
129
|
+
'publicEndpoint': publicEndpoint})
|
|
130
|
+
|
|
131
|
+
def insert(self, project='wrong_project',
|
|
132
|
+
body='wrong_public_endpoint_resource'):
|
|
133
|
+
return self.RegisterRequest({'project': project, 'body': body})
|
|
134
|
+
|
|
135
|
+
def delete(self, project='wrong_project',
|
|
136
|
+
publicEndpoint='wrong_public_endpoint'):
|
|
137
|
+
return self.RegisterRequest({'project': project,
|
|
138
|
+
'publicEndpoint': publicEndpoint})
|
|
139
|
+
|
|
140
|
+
def list(self, project='wrong_project'):
|
|
141
|
+
return self.RegisterRequest({'project': project})
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class MockNetworksApi(MockApiBase):
|
|
145
|
+
"""Mock return result of the MockApi.networks() method."""
|
|
146
|
+
|
|
147
|
+
def get(self, project='wrong_project', network='wrong_network'):
|
|
148
|
+
return self.RegisterRequest({'project': project, 'network': network})
|
|
149
|
+
|
|
150
|
+
def insert(self, project='wrong_project', body='wrong_network_resource'):
|
|
151
|
+
return self.RegisterRequest({'project': project, 'body': body})
|
|
152
|
+
|
|
153
|
+
def delete(self, project='wrong_project', network='wrong_network'):
|
|
154
|
+
return self.RegisterRequest({'project': project, 'network': network})
|
|
155
|
+
|
|
156
|
+
def list(self, project='wrong_project'):
|
|
157
|
+
return self.RegisterRequest({'project': project})
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class MockGlobalOperationsApi(MockApiBase):
|
|
161
|
+
"""Mock return result of the MockApi.globalOperations() method."""
|
|
162
|
+
|
|
163
|
+
def get(self, project='wrong_project', operation='wrong_operation', **kwargs):
|
|
164
|
+
return self.RegisterRequest({'project': project, 'operation': operation},
|
|
165
|
+
**kwargs)
|
|
166
|
+
|
|
167
|
+
def delete(self, project='wrong_project', operation='wrong_operation'):
|
|
168
|
+
return self.RegisterRequest({'project': project, 'operation': operation})
|
|
169
|
+
|
|
170
|
+
def list(self, project='wrong_project'):
|
|
171
|
+
return self.RegisterRequest({'project': project})
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class MockZoneOperationsApi(MockApiBase):
|
|
175
|
+
"""Mock return result of the MockApi.zoneOperations() method."""
|
|
176
|
+
|
|
177
|
+
def get(self, project='wrong_project', operation='wrong_operation',
|
|
178
|
+
zone='wrong_zone'):
|
|
179
|
+
return self.RegisterRequest({'project': project,
|
|
180
|
+
'operation': operation,
|
|
181
|
+
'zone': zone})
|
|
182
|
+
|
|
183
|
+
def delete(self, project='wrong_project', operation='wrong_operation',
|
|
184
|
+
zone='wrong_zone'):
|
|
185
|
+
return self.RegisterRequest({'project': project,
|
|
186
|
+
'operation': operation,
|
|
187
|
+
'zone': zone})
|
|
188
|
+
|
|
189
|
+
def list(self, project='wrong_project', zone='wrong_zone'):
|
|
190
|
+
return self.RegisterRequest({'project': project, 'zone': zone})
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class MockImagesApi(MockApiBase):
|
|
194
|
+
"""Mock return result of the MockApi.images() method."""
|
|
195
|
+
|
|
196
|
+
def get(self, project='wrong_project', image='wrong_image'):
|
|
197
|
+
return self.RegisterRequest({'project': project, 'image': image})
|
|
198
|
+
|
|
199
|
+
def insert(self, project='wrong_project', body='wrong_image_resource'):
|
|
200
|
+
return self.RegisterRequest({'project': project, 'body': body})
|
|
201
|
+
|
|
202
|
+
def delete(self, project='wrong_project', image='wrong_image'):
|
|
203
|
+
return self.RegisterRequest({'project': project, 'image': image})
|
|
204
|
+
|
|
205
|
+
def list(self, project='wrong_project', **unused_kwargs):
|
|
206
|
+
return self.RegisterRequest({'project': project})
|
|
207
|
+
|
|
208
|
+
def deprecate(self, project='wrong_project', image='wrong_image',
|
|
209
|
+
body='wrong_deprecation_resource'):
|
|
210
|
+
return self.RegisterRequest({'project': project, 'image': image,
|
|
211
|
+
'body': body})
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class MockInstancesApi(MockApiBase):
|
|
215
|
+
"""Mock return result of the MockApi.instances() method."""
|
|
216
|
+
|
|
217
|
+
def get(self, project='wrong_project', instance='wrong_instance', **kwargs):
|
|
218
|
+
return self.RegisterRequest({'project': project, 'instance': instance},
|
|
219
|
+
**kwargs)
|
|
220
|
+
|
|
221
|
+
def insert(self, project='wrong_project', body='wrong_instance_resource',
|
|
222
|
+
**kwargs):
|
|
223
|
+
return self.RegisterRequest({'project': project, 'body': body}, **kwargs)
|
|
224
|
+
|
|
225
|
+
def delete(self, project='wrong_project', instance='wrong_instance',
|
|
226
|
+
**kwargs):
|
|
227
|
+
return self.RegisterRequest({'project': project, 'instance': instance},
|
|
228
|
+
**kwargs)
|
|
229
|
+
|
|
230
|
+
def list(self, project='wrong_project', zone='wrong_zone', **unused_kwargs):
|
|
231
|
+
return self.RegisterRequest({'project': project, 'zone': zone})
|
|
232
|
+
|
|
233
|
+
def addAccessConfig(self, project='wrong_project', instance='wrong_instance',
|
|
234
|
+
network_interface='wrong_network_interface',
|
|
235
|
+
body='wrong_instance_resource', **kwargs):
|
|
236
|
+
return self.RegisterRequest({'project': project, 'instance': instance,
|
|
237
|
+
'network_interface': network_interface,
|
|
238
|
+
'body': body}, **kwargs)
|
|
239
|
+
|
|
240
|
+
def deleteAccessConfig(self, project='wrong_project',
|
|
241
|
+
instance='wrong_instance',
|
|
242
|
+
network_interface='wrong_network_interface',
|
|
243
|
+
access_config='wrong_access_config',
|
|
244
|
+
**kwargs):
|
|
245
|
+
return self.RegisterRequest({'project': project, 'instance': instance,
|
|
246
|
+
'network_interface': network_interface,
|
|
247
|
+
'access_config': access_config}, **kwargs)
|
|
248
|
+
|
|
249
|
+
def setMetadata(self, project='wrong_project', instance='wrong_instance',
|
|
250
|
+
body='wrong_metadata', zone='wrong_zone'):
|
|
251
|
+
return self.RegisterRequest({'project': project, 'instance': instance,
|
|
252
|
+
'body': body, 'zone': zone})
|
|
253
|
+
|
|
254
|
+
def setTags(self, project='wrong_project', instance='wrong_instance',
|
|
255
|
+
body='wrong_tags', zone='wrong_zone'):
|
|
256
|
+
return self.RegisterRequest({'project': project, 'instance': instance,
|
|
257
|
+
'body': body, 'zone': zone})
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class MockKernelsApi(MockApiBase):
|
|
261
|
+
"""Mock return result of the MockApi.kernels() method."""
|
|
262
|
+
|
|
263
|
+
def get(self, project='wrong_project', kernel='wrong_kernel'):
|
|
264
|
+
return self.RegisterRequest({'project': project, 'kernel': kernel})
|
|
265
|
+
|
|
266
|
+
def list(self, project='wrong_project'):
|
|
267
|
+
return self.RegisterRequest({'project': project})
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class MockMachineSpecsApi(MockApiBase):
|
|
271
|
+
"""Mock return result of the MockApi.machineSpecs() method."""
|
|
272
|
+
|
|
273
|
+
def get(self, machineSpec='wrong_machine_type'):
|
|
274
|
+
return self.RegisterRequest({'machineSpec': machineSpec})
|
|
275
|
+
|
|
276
|
+
def list(self):
|
|
277
|
+
return self.RegisterRequest('empty_result')
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
class MockMachineTypesApi(MockApiBase):
|
|
281
|
+
"""Mock return result of the MockApi.machineTypes() method."""
|
|
282
|
+
|
|
283
|
+
def get(self, machineType='wrong_machine_type', **unused_kwargs):
|
|
284
|
+
return self.RegisterRequest({'machineType': machineType})
|
|
285
|
+
|
|
286
|
+
def list(self, **unused_kwargs):
|
|
287
|
+
return self.RegisterRequest('empty_result')
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class MockProjectsApi(MockApiBase):
|
|
291
|
+
"""Mock return result of the MockApi.projects() method."""
|
|
292
|
+
|
|
293
|
+
def get(self, project='wrong_project'):
|
|
294
|
+
return self.RegisterRequest({'project': project})
|
|
295
|
+
|
|
296
|
+
def setCommonInstanceMetadata(self, project='wrong_project', body=None):
|
|
297
|
+
return self.RegisterRequest({'project': project,
|
|
298
|
+
'commonInstanceMetadata': body})
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
class MockSnapshotsApi(MockApiBase):
|
|
302
|
+
"""Mock return result of the MockApi.snapshots() method."""
|
|
303
|
+
|
|
304
|
+
def get(self, project='wrong_project', snapshot='wrong_snapshot', **kwargs):
|
|
305
|
+
return self.RegisterRequest({'project': project, 'snapshot': snapshot},
|
|
306
|
+
**kwargs)
|
|
307
|
+
|
|
308
|
+
def insert(self, project='wrong_project', body='wrong_snapshot_resource',
|
|
309
|
+
**kwargs):
|
|
310
|
+
return self.RegisterRequest({'project': project, 'body': body}, **kwargs)
|
|
311
|
+
|
|
312
|
+
def delete(self, project='wrong_project', snapshot='wrong_snapshot',
|
|
313
|
+
**kwargs):
|
|
314
|
+
return self.RegisterRequest({'project': project, 'snapshot': snapshot},
|
|
315
|
+
**kwargs)
|
|
316
|
+
|
|
317
|
+
def list(self, project='wrong_project', **kwargs):
|
|
318
|
+
return self.RegisterRequest({'project': project}, **kwargs)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
class MockZonesApi(MockApiBase):
|
|
322
|
+
"""Mock return result of the MockApi.zones() method."""
|
|
323
|
+
|
|
324
|
+
def get(self, zone='wrong_zone', **unused_kwargs):
|
|
325
|
+
return self.RegisterRequest({'zone': zone})
|
|
326
|
+
|
|
327
|
+
def list(self, **unused_kwargs):
|
|
328
|
+
return self.RegisterRequest('empty_result')
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
class MockApi(object):
|
|
332
|
+
"""Mock of the Google Compute Engine API returned by the discovery client."""
|
|
333
|
+
|
|
334
|
+
def disks(self):
|
|
335
|
+
return MockDisksApi()
|
|
336
|
+
|
|
337
|
+
def firewalls(self):
|
|
338
|
+
return MockFirewallsApi()
|
|
339
|
+
|
|
340
|
+
def backendGroups(self):
|
|
341
|
+
return MockBackendGroupsApi()
|
|
342
|
+
|
|
343
|
+
def publicEndpoints(self):
|
|
344
|
+
return MockPublicEndpointsApi()
|
|
345
|
+
|
|
346
|
+
def networks(self):
|
|
347
|
+
return MockNetworksApi()
|
|
348
|
+
|
|
349
|
+
def images(self):
|
|
350
|
+
return MockImagesApi()
|
|
351
|
+
|
|
352
|
+
def instances(self):
|
|
353
|
+
return MockInstancesApi()
|
|
354
|
+
|
|
355
|
+
def kernels(self):
|
|
356
|
+
return MockKernelsApi()
|
|
357
|
+
|
|
358
|
+
def machineSpecs(self):
|
|
359
|
+
return MockMachineSpecsApi()
|
|
360
|
+
|
|
361
|
+
def machineTypes(self):
|
|
362
|
+
return MockMachineTypesApi()
|
|
363
|
+
|
|
364
|
+
def projects(self):
|
|
365
|
+
return MockProjectsApi()
|
|
366
|
+
|
|
367
|
+
def operations(self):
|
|
368
|
+
return MockGlobalOperationsApi()
|
|
369
|
+
|
|
370
|
+
def zoneOperations(self):
|
|
371
|
+
return MockZoneOperationsApi()
|
|
372
|
+
|
|
373
|
+
def globalOperations(self):
|
|
374
|
+
return MockGlobalOperationsApi()
|
|
375
|
+
|
|
376
|
+
def snapshots(self):
|
|
377
|
+
return MockSnapshotsApi()
|
|
378
|
+
|
|
379
|
+
def zones(self):
|
|
380
|
+
return MockZonesApi()
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
class MockOutput(object):
|
|
384
|
+
"""Mock class used for capturing standard output in tests."""
|
|
385
|
+
|
|
386
|
+
def __init__(self):
|
|
387
|
+
self._capture_text = ''
|
|
388
|
+
|
|
389
|
+
# Purposefully name this 'write' to mock an output stream
|
|
390
|
+
# pylint: disable-msg=C6409
|
|
391
|
+
def write(self, text):
|
|
392
|
+
self._capture_text += text
|
|
393
|
+
|
|
394
|
+
# Purposefully name this 'flush' to mock an output stream
|
|
395
|
+
# pylint: disable-msg=C6409
|
|
396
|
+
def flush(self):
|
|
397
|
+
pass
|
|
398
|
+
|
|
399
|
+
def GetCapturedText(self):
|
|
400
|
+
return self._capture_text
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
class MockInput(object):
|
|
404
|
+
"""Mock class for standard input in tests."""
|
|
405
|
+
|
|
406
|
+
def __init__(self, input_string):
|
|
407
|
+
self._input_string = input_string
|
|
408
|
+
|
|
409
|
+
# Purposefully name this 'readline' to mock an input stream
|
|
410
|
+
# pylint: disable-msg=C6409
|
|
411
|
+
def readline(self):
|
|
412
|
+
return self._input_string
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
class MockCredential(object):
|
|
416
|
+
"""A mock credential that does nothing."""
|
|
417
|
+
|
|
418
|
+
def authorize(self, http):
|
|
419
|
+
return http
|
|
420
|
+
|