Path: blob/develop/tests/unit/customizations/codedeploy/test_locationargs.py
2637 views
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.1213from awscli.testutils import unittest14from awscli.testutils import BaseAWSCommandParamsTest151617class TestGetApplicationRevisionLocationArguments(18BaseAWSCommandParamsTest):1920prefix = 'deploy get-application-revision --application-name foo '2122def test_s3_location(self):23cmd = self.prefix + '--s3-location bucket=b,key=k,bundleType=zip'24result = {25'applicationName': 'foo',26'revision': {27'revisionType': 'S3',28's3Location': {29'bucket': 'b',30'key': 'k',31'bundleType': 'zip'32}33}34}35self.assert_params_for_cmd(cmd, result)3637def test_s3_location_with_etag(self):38cmd = self.prefix + (39'--s3-location bucket=b,key=k,'40'bundleType=zip,eTag=1234')41result = {42'applicationName': 'foo',43'revision': {44'revisionType': 'S3',45's3Location': {46'bucket': 'b',47'key': 'k',48'bundleType': 'zip',49'eTag': '1234'50}51}52}53self.assert_params_for_cmd(cmd, result)5455def test_s3_location_with_version(self):56cmd = self.prefix + (57'--s3-location bucket=b,key=k,'58'bundleType=zip,version=abcd')59result = {60'applicationName': 'foo',61'revision': {62'revisionType': 'S3',63's3Location': {64'bucket': 'b',65'key': 'k',66'bundleType': 'zip',67'version': 'abcd'68}69}70}71self.assert_params_for_cmd(cmd, result)7273def test_s3_location_with_etag_and_version(self):74cmd = self.prefix + (75'--s3-location bucket=b,key=k,'76'bundleType=zip,eTag=1234,version=abcd')77result = {78'applicationName': 'foo',79'revision': {80'revisionType': 'S3',81's3Location': {82'bucket': 'b',83'key': 'k',84'bundleType': 'zip',85'eTag': '1234',86'version': 'abcd'87}88}89}90self.assert_params_for_cmd(cmd, result)9192def test_s3_location_json(self):93cmd = self.prefix + (94'--s3-location {"bucket":"b","key":"k",'95'"bundleType":"zip","eTag":"1234","version":"abcd"}')96result = {97'applicationName': 'foo',98'revision': {99'revisionType': 'S3',100's3Location': {101'bucket': 'b',102'key': 'k',103'bundleType': 'zip',104'eTag': '1234',105'version': 'abcd'106}107}108}109self.assert_params_for_cmd(cmd, result)110111def test_s3_location_missing_bucket(self):112cmd = self.prefix + (113'--s3-location key=k,'114'bundleType=zip,eTag=1234,version=abcd')115self.run_cmd(cmd, 255)116117def test_s3_location_missing_key(self):118cmd = self.prefix + (119'--s3-location bucket=b,'120'bundleType=zip,eTag=1234,version=abcd')121self.run_cmd(cmd, 255)122123def test_github_location_with_etag(self):124cmd = self.prefix + (125'--github-location repository=foo/bar,'126'commitId=1234')127result = {128'applicationName': 'foo',129'revision': {130'revisionType': 'GitHub',131'gitHubLocation': {132'repository': 'foo/bar',133'commitId': '1234',134}135}136}137self.assert_params_for_cmd(cmd, result)138139def test_github_location_json(self):140cmd = self.prefix + (141'--github-location {"repository":"foo/bar",'142'"commitId":"1234"}')143result = {144'applicationName': 'foo',145'revision': {146'revisionType': 'GitHub',147'gitHubLocation': {148'repository': 'foo/bar',149'commitId': '1234',150}151}152}153self.assert_params_for_cmd(cmd, result)154155def test_github_location_missing_repository(self):156cmd = self.prefix + (157'--github-location '158'commitId=1234')159self.run_cmd(cmd, 255)160161def test_github_location_missing_commit_id(self):162cmd = self.prefix + '--github-location repository=foo/bar'163self.run_cmd(cmd, 255)164165166class TestRegisterApplicationRevisionLocationArguments(167BaseAWSCommandParamsTest):168169prefix = 'deploy register-application-revision --application-name foo '170171def test_s3_location(self):172cmd = self.prefix + '--s3-location bucket=b,key=k,bundleType=zip'173result = {174'applicationName': 'foo',175'revision': {176'revisionType': 'S3',177's3Location': {178'bucket': 'b',179'key': 'k',180'bundleType': 'zip'181}182}183}184self.assert_params_for_cmd(cmd, result)185186def test_s3_location_with_etag(self):187cmd = self.prefix + (188'--s3-location bucket=b,key=k,'189'bundleType=zip,eTag=1234')190result = {191'applicationName': 'foo',192'revision': {193'revisionType': 'S3',194's3Location': {195'bucket': 'b',196'key': 'k',197'bundleType': 'zip',198'eTag': '1234'199}200}201}202self.assert_params_for_cmd(cmd, result)203204def test_s3_location_with_version(self):205cmd = self.prefix + (206'--s3-location bucket=b,key=k,'207'bundleType=zip,version=abcd')208result = {209'applicationName': 'foo',210'revision': {211'revisionType': 'S3',212's3Location': {213'bucket': 'b',214'key': 'k',215'bundleType': 'zip',216'version': 'abcd'217}218}219}220self.assert_params_for_cmd(cmd, result)221222def test_s3_location_with_etag_and_version(self):223cmd = self.prefix + (224'--s3-location bucket=b,key=k,'225'bundleType=zip,eTag=1234,version=abcd')226result = {227'applicationName': 'foo',228'revision': {229'revisionType': 'S3',230's3Location': {231'bucket': 'b',232'key': 'k',233'bundleType': 'zip',234'eTag': '1234',235'version': 'abcd'236}237}238}239self.assert_params_for_cmd(cmd, result)240241def test_s3_location_json(self):242cmd = self.prefix + (243'--s3-location {"bucket":"b","key":"k",'244'"bundleType":"zip","eTag":"1234","version":"abcd"}')245result = {246'applicationName': 'foo',247'revision': {248'revisionType': 'S3',249's3Location': {250'bucket': 'b',251'key': 'k',252'bundleType': 'zip',253'eTag': '1234',254'version': 'abcd'255}256}257}258self.assert_params_for_cmd(cmd, result)259260def test_s3_location_missing_bucket(self):261cmd = self.prefix + (262'--s3-location key=k,'263'bundleType=zip,eTag=1234,version=abcd')264self.run_cmd(cmd, 255)265266def test_s3_location_missing_key(self):267cmd = self.prefix + (268'--s3-location bucket=b,'269'bundleType=zip,eTag=1234,version=abcd')270self.run_cmd(cmd, 255)271272def test_github_location_with_etag(self):273cmd = self.prefix + (274'--github-location repository=foo/bar,'275'commitId=1234')276result = {277'applicationName': 'foo',278'revision': {279'revisionType': 'GitHub',280'gitHubLocation': {281'repository': 'foo/bar',282'commitId': '1234',283}284}285}286self.assert_params_for_cmd(cmd, result)287288def test_github_location_json(self):289cmd = self.prefix + (290'--github-location {"repository":"foo/bar",'291'"commitId":"1234"}')292result = {293'applicationName': 'foo',294'revision': {295'revisionType': 'GitHub',296'gitHubLocation': {297'repository': 'foo/bar',298'commitId': '1234',299}300}301}302self.assert_params_for_cmd(cmd, result)303304def test_github_location_missing_repository(self):305cmd = self.prefix + (306'--github-location '307'commitId=1234')308self.run_cmd(cmd, 255)309310def test_github_location_missing_commit_id(self):311cmd = self.prefix + '--github-location repository=foo/bar'312self.run_cmd(cmd, 255)313314315class TestCreateDeploymentLocationArguments(316BaseAWSCommandParamsTest):317318prefix = (319'deploy create-deployment --application-name foo '320'--deployment-group bar ')321322def test_s3_location(self):323cmd = self.prefix + '--s3-location bucket=b,key=k,bundleType=zip'324result = {325'applicationName': 'foo',326'deploymentGroupName': 'bar',327'revision': {328'revisionType': 'S3',329's3Location': {330'bucket': 'b',331'key': 'k',332'bundleType': 'zip'333}334}335}336self.assert_params_for_cmd(cmd, result)337338def test_s3_location_with_etag(self):339cmd = self.prefix + (340'--s3-location bucket=b,key=k,'341'bundleType=zip,eTag=1234')342result = {343'applicationName': 'foo',344'deploymentGroupName': 'bar',345'revision': {346'revisionType': 'S3',347's3Location': {348'bucket': 'b',349'key': 'k',350'bundleType': 'zip',351'eTag': '1234'352}353}354}355self.assert_params_for_cmd(cmd, result)356357def test_s3_location_with_version(self):358cmd = self.prefix + (359'--s3-location bucket=b,key=k,'360'bundleType=zip,version=abcd')361result = {362'applicationName': 'foo',363'deploymentGroupName': 'bar',364'revision': {365'revisionType': 'S3',366's3Location': {367'bucket': 'b',368'key': 'k',369'bundleType': 'zip',370'version': 'abcd'371}372}373}374self.assert_params_for_cmd(cmd, result)375376def test_s3_location_with_etag_and_version(self):377cmd = self.prefix + (378'--s3-location bucket=b,key=k,'379'bundleType=zip,eTag=1234,version=abcd')380result = {381'applicationName': 'foo',382'deploymentGroupName': 'bar',383'revision': {384'revisionType': 'S3',385's3Location': {386'bucket': 'b',387'key': 'k',388'bundleType': 'zip',389'eTag': '1234',390'version': 'abcd'391}392}393}394self.assert_params_for_cmd(cmd, result)395396def test_s3_location_json(self):397cmd = self.prefix + (398'--s3-location {"bucket":"b","key":"k",'399'"bundleType":"zip","eTag":"1234","version":"abcd"}')400result = {401'applicationName': 'foo',402'deploymentGroupName': 'bar',403'revision': {404'revisionType': 'S3',405's3Location': {406'bucket': 'b',407'key': 'k',408'bundleType': 'zip',409'eTag': '1234',410'version': 'abcd'411}412}413}414self.assert_params_for_cmd(cmd, result)415416def test_s3_location_missing_bucket(self):417cmd = self.prefix + (418'--s3-location key=k,'419'bundleType=zip,eTag=1234,version=abcd')420self.run_cmd(cmd, 255)421422def test_s3_location_missing_key(self):423cmd = self.prefix + (424'--s3-location bucket=b,'425'bundleType=zip,eTag=1234,version=abcd')426self.run_cmd(cmd, 255)427428def test_github_location_with_etag(self):429cmd = self.prefix + (430'--github-location repository=foo/bar,'431'commitId=1234')432result = {433'applicationName': 'foo',434'deploymentGroupName': 'bar',435'revision': {436'revisionType': 'GitHub',437'gitHubLocation': {438'repository': 'foo/bar',439'commitId': '1234',440}441}442}443self.assert_params_for_cmd(cmd, result)444445def test_github_location_json(self):446cmd = self.prefix + (447'--github-location {"repository":"foo/bar",'448'"commitId":"1234"}')449result = {450'applicationName': 'foo',451'deploymentGroupName': 'bar',452'revision': {453'revisionType': 'GitHub',454'gitHubLocation': {455'repository': 'foo/bar',456'commitId': '1234',457}458}459}460self.assert_params_for_cmd(cmd, result)461462def test_github_location_missing_repository(self):463cmd = self.prefix + (464'--github-location '465'commitId=1234')466self.run_cmd(cmd, 255)467468def test_github_location_missing_commit_id(self):469cmd = self.prefix + '--github-location repository=foo/bar'470self.run_cmd(cmd, 255)471472473if __name__ == "__main__":474unittest.main()475476477