Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/unit/customizations/codedeploy/test_locationargs.py
2637 views
1
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
14
from awscli.testutils import unittest
15
from awscli.testutils import BaseAWSCommandParamsTest
16
17
18
class TestGetApplicationRevisionLocationArguments(
19
BaseAWSCommandParamsTest):
20
21
prefix = 'deploy get-application-revision --application-name foo '
22
23
def test_s3_location(self):
24
cmd = self.prefix + '--s3-location bucket=b,key=k,bundleType=zip'
25
result = {
26
'applicationName': 'foo',
27
'revision': {
28
'revisionType': 'S3',
29
's3Location': {
30
'bucket': 'b',
31
'key': 'k',
32
'bundleType': 'zip'
33
}
34
}
35
}
36
self.assert_params_for_cmd(cmd, result)
37
38
def test_s3_location_with_etag(self):
39
cmd = self.prefix + (
40
'--s3-location bucket=b,key=k,'
41
'bundleType=zip,eTag=1234')
42
result = {
43
'applicationName': 'foo',
44
'revision': {
45
'revisionType': 'S3',
46
's3Location': {
47
'bucket': 'b',
48
'key': 'k',
49
'bundleType': 'zip',
50
'eTag': '1234'
51
}
52
}
53
}
54
self.assert_params_for_cmd(cmd, result)
55
56
def test_s3_location_with_version(self):
57
cmd = self.prefix + (
58
'--s3-location bucket=b,key=k,'
59
'bundleType=zip,version=abcd')
60
result = {
61
'applicationName': 'foo',
62
'revision': {
63
'revisionType': 'S3',
64
's3Location': {
65
'bucket': 'b',
66
'key': 'k',
67
'bundleType': 'zip',
68
'version': 'abcd'
69
}
70
}
71
}
72
self.assert_params_for_cmd(cmd, result)
73
74
def test_s3_location_with_etag_and_version(self):
75
cmd = self.prefix + (
76
'--s3-location bucket=b,key=k,'
77
'bundleType=zip,eTag=1234,version=abcd')
78
result = {
79
'applicationName': 'foo',
80
'revision': {
81
'revisionType': 'S3',
82
's3Location': {
83
'bucket': 'b',
84
'key': 'k',
85
'bundleType': 'zip',
86
'eTag': '1234',
87
'version': 'abcd'
88
}
89
}
90
}
91
self.assert_params_for_cmd(cmd, result)
92
93
def test_s3_location_json(self):
94
cmd = self.prefix + (
95
'--s3-location {"bucket":"b","key":"k",'
96
'"bundleType":"zip","eTag":"1234","version":"abcd"}')
97
result = {
98
'applicationName': 'foo',
99
'revision': {
100
'revisionType': 'S3',
101
's3Location': {
102
'bucket': 'b',
103
'key': 'k',
104
'bundleType': 'zip',
105
'eTag': '1234',
106
'version': 'abcd'
107
}
108
}
109
}
110
self.assert_params_for_cmd(cmd, result)
111
112
def test_s3_location_missing_bucket(self):
113
cmd = self.prefix + (
114
'--s3-location key=k,'
115
'bundleType=zip,eTag=1234,version=abcd')
116
self.run_cmd(cmd, 255)
117
118
def test_s3_location_missing_key(self):
119
cmd = self.prefix + (
120
'--s3-location bucket=b,'
121
'bundleType=zip,eTag=1234,version=abcd')
122
self.run_cmd(cmd, 255)
123
124
def test_github_location_with_etag(self):
125
cmd = self.prefix + (
126
'--github-location repository=foo/bar,'
127
'commitId=1234')
128
result = {
129
'applicationName': 'foo',
130
'revision': {
131
'revisionType': 'GitHub',
132
'gitHubLocation': {
133
'repository': 'foo/bar',
134
'commitId': '1234',
135
}
136
}
137
}
138
self.assert_params_for_cmd(cmd, result)
139
140
def test_github_location_json(self):
141
cmd = self.prefix + (
142
'--github-location {"repository":"foo/bar",'
143
'"commitId":"1234"}')
144
result = {
145
'applicationName': 'foo',
146
'revision': {
147
'revisionType': 'GitHub',
148
'gitHubLocation': {
149
'repository': 'foo/bar',
150
'commitId': '1234',
151
}
152
}
153
}
154
self.assert_params_for_cmd(cmd, result)
155
156
def test_github_location_missing_repository(self):
157
cmd = self.prefix + (
158
'--github-location '
159
'commitId=1234')
160
self.run_cmd(cmd, 255)
161
162
def test_github_location_missing_commit_id(self):
163
cmd = self.prefix + '--github-location repository=foo/bar'
164
self.run_cmd(cmd, 255)
165
166
167
class TestRegisterApplicationRevisionLocationArguments(
168
BaseAWSCommandParamsTest):
169
170
prefix = 'deploy register-application-revision --application-name foo '
171
172
def test_s3_location(self):
173
cmd = self.prefix + '--s3-location bucket=b,key=k,bundleType=zip'
174
result = {
175
'applicationName': 'foo',
176
'revision': {
177
'revisionType': 'S3',
178
's3Location': {
179
'bucket': 'b',
180
'key': 'k',
181
'bundleType': 'zip'
182
}
183
}
184
}
185
self.assert_params_for_cmd(cmd, result)
186
187
def test_s3_location_with_etag(self):
188
cmd = self.prefix + (
189
'--s3-location bucket=b,key=k,'
190
'bundleType=zip,eTag=1234')
191
result = {
192
'applicationName': 'foo',
193
'revision': {
194
'revisionType': 'S3',
195
's3Location': {
196
'bucket': 'b',
197
'key': 'k',
198
'bundleType': 'zip',
199
'eTag': '1234'
200
}
201
}
202
}
203
self.assert_params_for_cmd(cmd, result)
204
205
def test_s3_location_with_version(self):
206
cmd = self.prefix + (
207
'--s3-location bucket=b,key=k,'
208
'bundleType=zip,version=abcd')
209
result = {
210
'applicationName': 'foo',
211
'revision': {
212
'revisionType': 'S3',
213
's3Location': {
214
'bucket': 'b',
215
'key': 'k',
216
'bundleType': 'zip',
217
'version': 'abcd'
218
}
219
}
220
}
221
self.assert_params_for_cmd(cmd, result)
222
223
def test_s3_location_with_etag_and_version(self):
224
cmd = self.prefix + (
225
'--s3-location bucket=b,key=k,'
226
'bundleType=zip,eTag=1234,version=abcd')
227
result = {
228
'applicationName': 'foo',
229
'revision': {
230
'revisionType': 'S3',
231
's3Location': {
232
'bucket': 'b',
233
'key': 'k',
234
'bundleType': 'zip',
235
'eTag': '1234',
236
'version': 'abcd'
237
}
238
}
239
}
240
self.assert_params_for_cmd(cmd, result)
241
242
def test_s3_location_json(self):
243
cmd = self.prefix + (
244
'--s3-location {"bucket":"b","key":"k",'
245
'"bundleType":"zip","eTag":"1234","version":"abcd"}')
246
result = {
247
'applicationName': 'foo',
248
'revision': {
249
'revisionType': 'S3',
250
's3Location': {
251
'bucket': 'b',
252
'key': 'k',
253
'bundleType': 'zip',
254
'eTag': '1234',
255
'version': 'abcd'
256
}
257
}
258
}
259
self.assert_params_for_cmd(cmd, result)
260
261
def test_s3_location_missing_bucket(self):
262
cmd = self.prefix + (
263
'--s3-location key=k,'
264
'bundleType=zip,eTag=1234,version=abcd')
265
self.run_cmd(cmd, 255)
266
267
def test_s3_location_missing_key(self):
268
cmd = self.prefix + (
269
'--s3-location bucket=b,'
270
'bundleType=zip,eTag=1234,version=abcd')
271
self.run_cmd(cmd, 255)
272
273
def test_github_location_with_etag(self):
274
cmd = self.prefix + (
275
'--github-location repository=foo/bar,'
276
'commitId=1234')
277
result = {
278
'applicationName': 'foo',
279
'revision': {
280
'revisionType': 'GitHub',
281
'gitHubLocation': {
282
'repository': 'foo/bar',
283
'commitId': '1234',
284
}
285
}
286
}
287
self.assert_params_for_cmd(cmd, result)
288
289
def test_github_location_json(self):
290
cmd = self.prefix + (
291
'--github-location {"repository":"foo/bar",'
292
'"commitId":"1234"}')
293
result = {
294
'applicationName': 'foo',
295
'revision': {
296
'revisionType': 'GitHub',
297
'gitHubLocation': {
298
'repository': 'foo/bar',
299
'commitId': '1234',
300
}
301
}
302
}
303
self.assert_params_for_cmd(cmd, result)
304
305
def test_github_location_missing_repository(self):
306
cmd = self.prefix + (
307
'--github-location '
308
'commitId=1234')
309
self.run_cmd(cmd, 255)
310
311
def test_github_location_missing_commit_id(self):
312
cmd = self.prefix + '--github-location repository=foo/bar'
313
self.run_cmd(cmd, 255)
314
315
316
class TestCreateDeploymentLocationArguments(
317
BaseAWSCommandParamsTest):
318
319
prefix = (
320
'deploy create-deployment --application-name foo '
321
'--deployment-group bar ')
322
323
def test_s3_location(self):
324
cmd = self.prefix + '--s3-location bucket=b,key=k,bundleType=zip'
325
result = {
326
'applicationName': 'foo',
327
'deploymentGroupName': 'bar',
328
'revision': {
329
'revisionType': 'S3',
330
's3Location': {
331
'bucket': 'b',
332
'key': 'k',
333
'bundleType': 'zip'
334
}
335
}
336
}
337
self.assert_params_for_cmd(cmd, result)
338
339
def test_s3_location_with_etag(self):
340
cmd = self.prefix + (
341
'--s3-location bucket=b,key=k,'
342
'bundleType=zip,eTag=1234')
343
result = {
344
'applicationName': 'foo',
345
'deploymentGroupName': 'bar',
346
'revision': {
347
'revisionType': 'S3',
348
's3Location': {
349
'bucket': 'b',
350
'key': 'k',
351
'bundleType': 'zip',
352
'eTag': '1234'
353
}
354
}
355
}
356
self.assert_params_for_cmd(cmd, result)
357
358
def test_s3_location_with_version(self):
359
cmd = self.prefix + (
360
'--s3-location bucket=b,key=k,'
361
'bundleType=zip,version=abcd')
362
result = {
363
'applicationName': 'foo',
364
'deploymentGroupName': 'bar',
365
'revision': {
366
'revisionType': 'S3',
367
's3Location': {
368
'bucket': 'b',
369
'key': 'k',
370
'bundleType': 'zip',
371
'version': 'abcd'
372
}
373
}
374
}
375
self.assert_params_for_cmd(cmd, result)
376
377
def test_s3_location_with_etag_and_version(self):
378
cmd = self.prefix + (
379
'--s3-location bucket=b,key=k,'
380
'bundleType=zip,eTag=1234,version=abcd')
381
result = {
382
'applicationName': 'foo',
383
'deploymentGroupName': 'bar',
384
'revision': {
385
'revisionType': 'S3',
386
's3Location': {
387
'bucket': 'b',
388
'key': 'k',
389
'bundleType': 'zip',
390
'eTag': '1234',
391
'version': 'abcd'
392
}
393
}
394
}
395
self.assert_params_for_cmd(cmd, result)
396
397
def test_s3_location_json(self):
398
cmd = self.prefix + (
399
'--s3-location {"bucket":"b","key":"k",'
400
'"bundleType":"zip","eTag":"1234","version":"abcd"}')
401
result = {
402
'applicationName': 'foo',
403
'deploymentGroupName': 'bar',
404
'revision': {
405
'revisionType': 'S3',
406
's3Location': {
407
'bucket': 'b',
408
'key': 'k',
409
'bundleType': 'zip',
410
'eTag': '1234',
411
'version': 'abcd'
412
}
413
}
414
}
415
self.assert_params_for_cmd(cmd, result)
416
417
def test_s3_location_missing_bucket(self):
418
cmd = self.prefix + (
419
'--s3-location key=k,'
420
'bundleType=zip,eTag=1234,version=abcd')
421
self.run_cmd(cmd, 255)
422
423
def test_s3_location_missing_key(self):
424
cmd = self.prefix + (
425
'--s3-location bucket=b,'
426
'bundleType=zip,eTag=1234,version=abcd')
427
self.run_cmd(cmd, 255)
428
429
def test_github_location_with_etag(self):
430
cmd = self.prefix + (
431
'--github-location repository=foo/bar,'
432
'commitId=1234')
433
result = {
434
'applicationName': 'foo',
435
'deploymentGroupName': 'bar',
436
'revision': {
437
'revisionType': 'GitHub',
438
'gitHubLocation': {
439
'repository': 'foo/bar',
440
'commitId': '1234',
441
}
442
}
443
}
444
self.assert_params_for_cmd(cmd, result)
445
446
def test_github_location_json(self):
447
cmd = self.prefix + (
448
'--github-location {"repository":"foo/bar",'
449
'"commitId":"1234"}')
450
result = {
451
'applicationName': 'foo',
452
'deploymentGroupName': 'bar',
453
'revision': {
454
'revisionType': 'GitHub',
455
'gitHubLocation': {
456
'repository': 'foo/bar',
457
'commitId': '1234',
458
}
459
}
460
}
461
self.assert_params_for_cmd(cmd, result)
462
463
def test_github_location_missing_repository(self):
464
cmd = self.prefix + (
465
'--github-location '
466
'commitId=1234')
467
self.run_cmd(cmd, 255)
468
469
def test_github_location_missing_commit_id(self):
470
cmd = self.prefix + '--github-location repository=foo/bar'
471
self.run_cmd(cmd, 255)
472
473
474
if __name__ == "__main__":
475
unittest.main()
476
477