Path: blob/develop/tests/functional/route53/test_resource_id.py
1567 views
#!/usr/bin/env python1# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License"). You4# may not use this file except in compliance with the License. A copy of5# the License is located at6#7# http://aws.amazon.com/apache2.0/8#9# or in the "license" file accompanying this file. This file is10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF11# ANY KIND, either express or implied. See the License for the specific12# language governing permissions and limitations under the License.13from awscli.testutils import BaseAWSCommandParamsTest141516CHANGEBATCH_JSON = ('{"Comment":"string","Changes":['17'{"Action":"CREATE","ResourceRecordSet":{'18'"Name":"test-foo.bar.com",'19'"Type":"CNAME",'20'"TTL":300,'21'"ResourceRecords":['22'{"Value":"foo-bar-com"}'23']}}]}')242526class TestGetHostedZone(BaseAWSCommandParamsTest):2728prefix = 'route53 get-hosted-zone'2930def setUp(self):31super(TestGetHostedZone, self).setUp()3233def test_full_resource_id(self):34args = ' --id /hostedzone/ZD3IYMVP1KDDM'35cmdline = self.prefix + args36self.assert_params_for_cmd(37cmdline, {'Id': 'ZD3IYMVP1KDDM'}, expected_rc=0)3839def test_short_resource_id(self):40args = ' --id ZD3IYMVP1KDDM'41cmdline = self.prefix + args42self.assert_params_for_cmd(43cmdline, {'Id': 'ZD3IYMVP1KDDM'},44expected_rc=0)454647class TestChangeResourceRecord(BaseAWSCommandParamsTest):4849prefix = 'route53 change-resource-record-sets'5051def setUp(self):52super(TestChangeResourceRecord, self).setUp()5354def test_full_resource_id(self):55args = ' --hosted-zone-id /change/ZD3IYMVP1KDDM'56args += ' --change-batch %s' % CHANGEBATCH_JSON57cmdline = self.prefix + args58expected = {59"HostedZoneId": "ZD3IYMVP1KDDM",60"ChangeBatch": {61"Comment": "string",62"Changes": [63{64"Action": "CREATE",65"ResourceRecordSet": {66"Name": "test-foo.bar.com",67"Type": "CNAME",68"TTL": 300,69"ResourceRecords": [70{71"Value": "foo-bar-com"72}73]74}75}76]77}78}79self.assert_params_for_cmd(cmdline, expected, expected_rc=0)808182class TestGetChange(BaseAWSCommandParamsTest):8384prefix = 'route53 get-change'8586def setUp(self):87super(TestGetChange, self).setUp()8889def test_full_resource_id(self):90args = ' --id /change/ZD3IYMVP1KDDM'91cmdline = self.prefix + args92expected = {'Id': 'ZD3IYMVP1KDDM'}93self.assert_params_for_cmd(cmdline, expected, expected_rc=0)9495def test_short_resource_id(self):96args = ' --id ZD3IYMVP1KDDM'97cmdline = self.prefix + args98expected = {'Id': 'ZD3IYMVP1KDDM'}99self.assert_params_for_cmd(cmdline, expected, expected_rc=0)100101102class TestReusableDelegationSet(BaseAWSCommandParamsTest):103104prefix = 'route53 get-reusable-delegation-set'105106def setUp(self):107super(TestReusableDelegationSet, self).setUp()108109def test_full_resource_id(self):110args = ' --id /delegationset/N9INWVYQ6Q0FN'111cmdline = self.prefix + args112self.assert_params_for_cmd(cmdline, {'Id': 'N9INWVYQ6Q0FN'},113expected_rc=0)114115def test_short_resource_id(self):116args = ' --id N9INWVYQ6Q0FN'117cmdline = self.prefix + args118self.assert_params_for_cmd(cmdline, {'Id': 'N9INWVYQ6Q0FN'},119expected_rc=0)120121122class TestMaxItems(BaseAWSCommandParamsTest):123124prefix = 'route53 list-resource-record-sets'125126def test_full_resource_id(self):127args = ' --hosted-zone-id /hostedzone/ABCD --max-items 1'128cmdline = self.prefix + args129expected = {'HostedZoneId': 'ABCD'}130self.assert_params_for_cmd(cmdline, expected, expected_rc=0)131132133