Path: blob/develop/tests/functional/configure/test_addmodel.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.12import json13import os1415from awscli.testutils import BaseAWSCommandParamsTest, FileCreator161718class TestAddModel(BaseAWSCommandParamsTest):19prefix = 'configure add-model'2021def setUp(self):22super(TestAddModel, self).setUp()23self.files = FileCreator()24self.customer_data_root = self.files.rootdir25self.data_loader = self.driver.session.get_component('data_loader')26self.data_loader.CUSTOMER_DATA_PATH = self.customer_data_root27self.service_definition = {28"version": "2.0",29"metadata": {30"apiVersion": '2015-12-02',31"endpointPrefix": 'myservice',32},33"operations": {},34"shapes": {}35}36self.service_unicode_definition = {37"version": "2.0",38"metadata": {39"apiVersion": '2015-12-02',40"endpointPrefix": 'myservice',41"keyWithUnicode": u'\u2713'42},43"operations": {},44"shapes": {}45}4647def tearDown(self):48super(TestAddModel, self).tearDown()49self.files.remove_all()5051def test_add_model(self):52cmdline = self.prefix + ' --service-model %s' % json.dumps(53self.service_definition, separators=(',', ':'))54self.run_cmd(cmdline)5556# Ensure that the model exists in the correct location.57self.assertTrue(58os.path.exists(os.path.join(59self.customer_data_root, 'myservice', '2015-12-02',60'service-2.json')))6162def test_add_model_with_unicode(self):63cmdline = self.prefix + ' --service-model %s' % json.dumps(64self.service_unicode_definition, separators=(',', ':'))65self.run_cmd(cmdline)6667# Ensure that the model exists in the correct location.68self.assertTrue(69os.path.exists(os.path.join(70self.customer_data_root, 'myservice', '2015-12-02',71'service-2.json')))7273def test_add_model_with_service_name(self):74cmdline = self.prefix + ' --service-model %s' % json.dumps(75self.service_definition, separators=(',', ':'))76cmdline += ' --service-name override-name'77self.run_cmd(cmdline)7879# Ensure that the model exists in the correct location.80self.assertTrue(81os.path.exists(os.path.join(82self.customer_data_root, 'override-name', '2015-12-02',83'service-2.json')))848586