Path: blob/develop/tests/functional/cloudfront/test_create_invalidation.py
1567 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.12from awscli.testutils import mock13from awscli.testutils import BaseAWSPreviewCommandParamsTest as \14BaseAWSCommandParamsTest151617class TestCreateInvalidation(BaseAWSCommandParamsTest):1819prefix = 'cloudfront create-invalidation --distribution-id my_id '2021def test_invalidation_batch_only(self):22batch = "Paths={Quantity=2,Items=[foo.txt,bar.txt]},CallerReference=ab"23cmdline = self.prefix + '--invalidation-batch ' + batch24result = {25'DistributionId': 'my_id',26'InvalidationBatch': {27'Paths': {'Items': ['foo.txt', 'bar.txt'], 'Quantity': 2},28'CallerReference': 'ab',29},30}31self.assert_params_for_cmd(cmdline, result)3233def test_paths_only(self):34cmdline = self.prefix + '--paths index.html foo.txt'35result = {36'DistributionId': 'my_id',37'InvalidationBatch': {38'Paths': {'Items': ['index.html', 'foo.txt'], 'Quantity': 2},39'CallerReference': mock.ANY,40},41}42self.run_cmd(cmdline)43self.assertEqual(self.last_kwargs, result)4445def test_invalidation_batch_and_paths(self):46cmdline = self.prefix + '--invalidation-batch {} --paths foo'47self.run_cmd(cmdline, expected_rc=255)4849def test_neither_invalidation_batch_or_paths(self):50self.run_cmd(self.prefix, expected_rc=255)515253