1 # 2 # Copyright 2016 Google Inc. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 """Test for generated servicemanagement messages module.""" 17 18 import unittest2 19 20 from apitools.base.py import extra_types 21 22 from samples.servicemanagement_sample.servicemanagement_v1 \ 23 import servicemanagement_v1_messages as messages # nopep8 24 25 26 class MessagesTest(unittest2.TestCase): 27 28 def testInstantiateMessageWithAdditionalProperties(self): 29 PROJECT_NAME = 'test-project' 30 SERVICE_NAME = 'test-service' 31 SERVICE_VERSION = '1.0' 32 33 prop = messages.Operation.ResponseValue.AdditionalProperty 34 messages.Operation( 35 name='operation-12345-67890', 36 done=False, 37 response=messages.Operation.ResponseValue( 38 additionalProperties=[ 39 prop(key='producerProjectId', 40 value=extra_types.JsonValue( 41 string_value=PROJECT_NAME)), 42 prop(key='serviceName', 43 value=extra_types.JsonValue( 44 string_value=SERVICE_NAME)), 45 prop(key='serviceConfig', 46 value=extra_types.JsonValue( 47 object_value=extra_types.JsonObject( 48 properties=[ 49 extra_types.JsonObject.Property( 50 key='id', 51 value=extra_types.JsonValue( 52 string_value=SERVICE_VERSION) 53 ) 54 ]) 55 )) 56 ])) 57