Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/functional/cloudfront/test_create_invalidation.py
1567 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
from awscli.testutils import mock
14
from awscli.testutils import BaseAWSPreviewCommandParamsTest as \
15
BaseAWSCommandParamsTest
16
17
18
class TestCreateInvalidation(BaseAWSCommandParamsTest):
19
20
prefix = 'cloudfront create-invalidation --distribution-id my_id '
21
22
def test_invalidation_batch_only(self):
23
batch = "Paths={Quantity=2,Items=[foo.txt,bar.txt]},CallerReference=ab"
24
cmdline = self.prefix + '--invalidation-batch ' + batch
25
result = {
26
'DistributionId': 'my_id',
27
'InvalidationBatch': {
28
'Paths': {'Items': ['foo.txt', 'bar.txt'], 'Quantity': 2},
29
'CallerReference': 'ab',
30
},
31
}
32
self.assert_params_for_cmd(cmdline, result)
33
34
def test_paths_only(self):
35
cmdline = self.prefix + '--paths index.html foo.txt'
36
result = {
37
'DistributionId': 'my_id',
38
'InvalidationBatch': {
39
'Paths': {'Items': ['index.html', 'foo.txt'], 'Quantity': 2},
40
'CallerReference': mock.ANY,
41
},
42
}
43
self.run_cmd(cmdline)
44
self.assertEqual(self.last_kwargs, result)
45
46
def test_invalidation_batch_and_paths(self):
47
cmdline = self.prefix + '--invalidation-batch {} --paths foo'
48
self.run_cmd(cmdline, expected_rc=255)
49
50
def test_neither_invalidation_batch_or_paths(self):
51
self.run_cmd(self.prefix, expected_rc=255)
52
53