Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/functional/configure/test_addmodel.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
import json
14
import os
15
16
from awscli.testutils import BaseAWSCommandParamsTest, FileCreator
17
18
19
class TestAddModel(BaseAWSCommandParamsTest):
20
prefix = 'configure add-model'
21
22
def setUp(self):
23
super(TestAddModel, self).setUp()
24
self.files = FileCreator()
25
self.customer_data_root = self.files.rootdir
26
self.data_loader = self.driver.session.get_component('data_loader')
27
self.data_loader.CUSTOMER_DATA_PATH = self.customer_data_root
28
self.service_definition = {
29
"version": "2.0",
30
"metadata": {
31
"apiVersion": '2015-12-02',
32
"endpointPrefix": 'myservice',
33
},
34
"operations": {},
35
"shapes": {}
36
}
37
self.service_unicode_definition = {
38
"version": "2.0",
39
"metadata": {
40
"apiVersion": '2015-12-02',
41
"endpointPrefix": 'myservice',
42
"keyWithUnicode": u'\u2713'
43
},
44
"operations": {},
45
"shapes": {}
46
}
47
48
def tearDown(self):
49
super(TestAddModel, self).tearDown()
50
self.files.remove_all()
51
52
def test_add_model(self):
53
cmdline = self.prefix + ' --service-model %s' % json.dumps(
54
self.service_definition, separators=(',', ':'))
55
self.run_cmd(cmdline)
56
57
# Ensure that the model exists in the correct location.
58
self.assertTrue(
59
os.path.exists(os.path.join(
60
self.customer_data_root, 'myservice', '2015-12-02',
61
'service-2.json')))
62
63
def test_add_model_with_unicode(self):
64
cmdline = self.prefix + ' --service-model %s' % json.dumps(
65
self.service_unicode_definition, separators=(',', ':'))
66
self.run_cmd(cmdline)
67
68
# Ensure that the model exists in the correct location.
69
self.assertTrue(
70
os.path.exists(os.path.join(
71
self.customer_data_root, 'myservice', '2015-12-02',
72
'service-2.json')))
73
74
def test_add_model_with_service_name(self):
75
cmdline = self.prefix + ' --service-model %s' % json.dumps(
76
self.service_definition, separators=(',', ':'))
77
cmdline += ' --service-name override-name'
78
self.run_cmd(cmdline)
79
80
# Ensure that the model exists in the correct location.
81
self.assertTrue(
82
os.path.exists(os.path.join(
83
self.customer_data_root, 'override-name', '2015-12-02',
84
'service-2.json')))
85
86