FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
aws-cli/tests/functional/test_preview.py at develop · dazcode/aws-cli · GitHub
dazcode
/
aws-cli
Public
forked from
aws/aws-cli
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
aws-cli
/
tests
/
functional
/
test_preview.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
92 lines (81 loc) · 4.19 KB
Breadcrumbs
aws-cli
/
tests
/
functional
/
test_preview.py
Copy path
File metadata and controls
92 lines (81 loc) · 4.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
import
mock
from
awscli
.
compat
import
six
from
awscli
.
customizations
import
preview
from
awscli
.
testutils
import
BaseAWSCommandParamsTest
class
TestPreviewMode
(
BaseAWSCommandParamsTest
):
def
setUp
(
self
):
super
(
TestPreviewMode
,
self
).
setUp
()
self
.
stderr
=
six
.
StringIO
()
self
.
stderr_patch
=
mock
.
patch
(
'sys.stderr'
,
self
.
stderr
)
self
.
stderr_patch
.
start
()
self
.
full_config
=
{
'profiles'
: {}}
# Implementation detail, but we want to patch out the
# session config, as that's the only way to control
# preview services.
self
.
driver
.
session
.
_config
=
self
.
full_config
def
tearDown
(
self
):
super
(
TestPreviewMode
,
self
).
tearDown
()
self
.
stderr_patch
.
stop
()
def
test_invoke_preview_mode_service
(
self
):
# By default cloudfront is a preview service.
# We check this to make sure we fail loudly if we
# ever mark cloudfront as not being a preview service
# by default.
self
.
assertIn
(
'cloudfront'
,
preview
.
PREVIEW_SERVICES
)
rc
=
self
.
driver
.
main
(
'cloudfront list-distributions'
.
split
())
self
.
assertEqual
(
rc
,
1
)
self
.
assertIn
(
preview
.
PreviewModeCommandMixin
.
HELP_SNIPPET
,
self
.
stderr
.
getvalue
())
def
test_preview_service_not_true
(
self
):
# If it's not "true" then we still make it a preview service.
self
.
full_config
[
'preview'
]
=
{
'cloudfront'
:
'false'
}
rc
=
self
.
driver
.
main
(
'cloudfront list-distributions'
.
split
())
self
.
assertEqual
(
rc
,
1
)
self
.
assertIn
(
preview
.
PreviewModeCommandMixin
.
HELP_SNIPPET
,
self
.
stderr
.
getvalue
())
def
test_preview_service_enabled_makes_call
(
self
):
self
.
full_config
[
'preview'
]
=
{
'cloudfront'
:
'true'
}
self
.
assert_params_for_cmd
(
'cloudfront list-distributions'
,
params
=
{})
@
mock
.
patch
(
'awscli.help.get_renderer'
)
def
test_can_still_document_preview_service
(
self
,
get_renderer
):
# Even if a service is still marked as being in preview,
# you can still pull up its documentation.
self
.
full_config
[
'preview'
]
=
{
'cloudfront'
:
'false'
}
self
.
driver
.
main
(
'cloudfront help'
.
split
())
# In this case, the normal help processing should have occurred
# and we check that we rendered the contents correctly.
self
.
assertTrue
(
get_renderer
.
return_value
.
render
.
called
)
contents
=
get_renderer
.
return_value
.
render
.
call_args
[
0
][
0
]
self
.
assertIn
(
'aws configure set preview.cloudfront true'
,
contents
.
decode
(
'utf-8'
))
@
mock
.
patch
(
'awscli.help.get_renderer'
)
def
test_document_preview_service_operation
(
self
,
get_renderer
):
# Even if a service is still marked as being in preview,
# you can still pull up its documentation for its operations.
self
.
full_config
[
'preview'
]
=
{
'cloudfront'
:
'false'
}
self
.
driver
.
main
(
'cloudfront create-distribution help'
.
split
())
# The contents should be have the correct way to set the command
# out of preview in the config file.
self
.
assertTrue
(
get_renderer
.
return_value
.
render
.
called
)
contents
=
get_renderer
.
return_value
.
render
.
call_args
[
0
][
0
]
self
.
assertIn
(
'aws configure set preview.cloudfront true'
,
contents
.
decode
(
'utf-8'
))
@
mock
.
patch
(
'awscli.help.get_renderer'
)
def
test_preview_mode_is_in_provider_help
(
self
,
renderer
):
self
.
driver
.
main
([
'help'
])
contents
=
renderer
.
return_value
.
render
.
call_args
[
0
][
0
]
# The preview services should still be in the help output.
for
service
in
preview
.
PREVIEW_SERVICES
:
self
.
assertIn
(
service
,
contents
.
decode
(
'utf-8'
))
Back
|
FazBrowse Home
|
New Git URL