示例#1
0
 def test_service_name_can_be_overriden(self):
     service_model = model.ServiceModel(self.model,
                                        service_name='myservice')
     self.assertEqual(service_model.service_name, 'myservice')
示例#2
0
 def test_wire_name_always_matches_model(self):
     service_model = model.ServiceModel(self.model)
     operation = model.OperationModel(
         self.model['operations']['OperationName'], service_model, 'Foo')
     self.assertEqual(operation.name, 'Foo')
     self.assertEqual(operation.wire_name, 'OperationName')
示例#3
0
 def test_endpoint_discovery_required(self):
     operation = self.model['operations']['OperationName']
     operation['endpointdiscovery'] = {'required': True}
     service_model = model.ServiceModel(self.model)
     self.assertTrue(service_model.endpoint_discovery_required)
示例#4
0
 def test_not_streaming_output_for_operation(self):
     self.remove_payload('Response')
     service_model = model.ServiceModel(self.model)
     operation = service_model.operation_model('OperationName')
     self.assertFalse(operation.has_streaming_output)
     self.assertEqual(operation.get_streaming_output(), None)
示例#5
0
 def test_has_documentation_property(self):
     service_model = model.ServiceModel(self.model)
     operation = service_model.operation_model('OperationName')
     self.assertEqual(operation.documentation, 'Docs for OperationName')
示例#6
0
 def test_operation_output_model(self):
     service_model = model.ServiceModel(self.model)
     operation = service_model.operation_model('OperationName')
     output = operation.output_shape
     self.assertEqual(list(output.members), ['String'])
     self.assertFalse(operation.has_streaming_output)
示例#7
0
 def test_endpoint_operation_present_false(self):
     self.model['operations']['OperationName']['endpointoperation'] = False
     service_model = model.ServiceModel(self.model)
     operation_name = service_model.operation_model('OperationName')
     self.assertFalse(operation_name.is_endpoint_discovery_operation)
示例#8
0
 def test_name_from_service(self):
     service_model = model.ServiceModel(self.model)
     operation = service_model.operation_model('OperationName')
     self.assertEqual(operation.name, 'OperationName')
示例#9
0
 def setUp(self):
     self.model = {
         'metadata': {
             'protocol': 'query',
             'endpointPrefix': 'foo'
         },
         'documentation': '',
         'operations': {
             'OperationName': {
                 'http': {
                     'method': 'POST',
                     'requestUri': '/',
                 },
                 'name': 'OperationName',
                 'input': {
                     'shape': 'OperationNameRequest'
                 },
                 'output': {
                     'shape': 'OperationNameResponse',
                 },
                 'errors': [{
                     'shape': 'NoSuchResourceException'
                 }],
                 'documentation': 'Docs for OperationName',
                 'authtype': 'v4'
             },
             'OperationTwo': {
                 'http': {
                     'method': 'POST',
                     'requestUri': '/',
                 },
                 'name': 'OperationTwo',
                 'input': {
                     'shape': 'OperationNameRequest'
                 },
                 'output': {
                     'shape': 'OperationNameResponse',
                 },
                 'errors': [{
                     'shape': 'NoSuchResourceException'
                 }],
                 'documentation': 'Docs for OperationTwo',
             }
         },
         'shapes': {
             'OperationNameRequest': {
                 'type': 'structure',
                 'members': {
                     'Arg1': {
                         'shape': 'stringType'
                     },
                     'Arg2': {
                         'shape': 'stringType'
                     },
                 }
             },
             'OperationNameResponse': {
                 'type': 'structure',
                 'members': {
                     'String': {
                         'shape': 'stringType',
                     }
                 }
             },
             'NoSuchResourceException': {
                 'type': 'structure',
                 'members': {}
             },
             'stringType': {
                 'type': 'string',
             }
         }
     }
     self.service_model = model.ServiceModel(self.model)
示例#10
0
 def test_deprecated_absent(self):
     service_model = model.ServiceModel(self.model)
     operation_two = service_model.operation_model('OperationTwo')
     self.assertFalse(operation_two.deprecated)
示例#11
0
def get_operation_model_with_retries():
    service = model.ServiceModel(SERVICE_DESCRIPTION_WITH_RETRIES,
                                 service_name='my-service')
    return service.operation_model('TestOperation')
示例#12
0
 def test_endpoint_discovery_required_no_value(self):
     operation = self.model['operations']['OperationName']
     self.assertTrue(operation.get('endpointdiscovery') is None)
     service_model = model.ServiceModel(self.model)
     self.assertFalse(service_model.endpoint_discovery_required)
示例#13
0
 def test_endpoint_discovery_required_false(self):
     self.model['operations']['OperationName']['endpointdiscovery'] = {}
     service_model = model.ServiceModel(self.model)
     self.assertFalse(service_model.endpoint_discovery_required)
示例#14
0
 def test_operation_name_in_repr(self):
     service_model = model.ServiceModel(self.model)
     operation = service_model.operation_model('OperationName')
     self.assertIn('OperationName', repr(operation))
示例#15
0
 def test_endpoint_discovery_present(self):
     operation = self.model['operations']['OperationName']
     operation['endpointdiscovery'] = {'required': True}
     service_model = model.ServiceModel(self.model)
     operation_name = service_model.operation_model('OperationName')
     self.assertTrue(operation_name.endpoint_discovery.get('required'))
示例#16
0
 def test_name_and_wire_name_defaults_to_same_value(self):
     service_model = model.ServiceModel(self.model)
     operation = model.OperationModel(
         self.model['operations']['OperationName'], service_model)
     self.assertEqual(operation.name, 'OperationName')
     self.assertEqual(operation.wire_name, 'OperationName')
示例#17
0
 def test_event_stream_output_for_operation(self):
     service_model = model.ServiceModel(self.model)
     operation = service_model.operation_model('OperationName')
     self.assertTrue(operation.has_event_stream_output)
     output = operation.get_event_stream_output()
     self.assertEqual(output.name, 'EventStreamStructure')
示例#18
0
 def test_name_from_service_model_when_differs_from_name(self):
     self.model['operations']['Foo'] = \
         self.model['operations']['OperationName']
     service_model = model.ServiceModel(self.model)
     operation = service_model.operation_model('Foo')
     self.assertEqual(operation.name, 'Foo')
示例#19
0
 def test_no_event_stream_output_for_operation(self):
     self.update_operation(output={'shape': 'NormalStructure'})
     service_model = model.ServiceModel(self.model)
     operation = service_model.operation_model('OperationName')
     self.assertFalse(operation.has_event_stream_output)
     self.assertEqual(operation.get_event_stream_output(), None)
示例#20
0
 def test_service_model_available_from_operation_model(self):
     service_model = model.ServiceModel(self.model)
     operation = service_model.operation_model('OperationName')
     # This is an identity comparison because we don't implement
     # __eq__, so we may need to change this in the future.
     self.assertEqual(operation.service_model, service_model)
示例#21
0
 def test_streaming_output_for_operation(self):
     service_model = model.ServiceModel(self.model)
     operation = service_model.operation_model('OperationName')
     self.assertTrue(operation.has_streaming_output)
     self.assertEqual(operation.get_streaming_output().name, 'blobType')
示例#22
0
 def test_deprecated_present_false(self):
     self.model['operations']['OperationName']['deprecated'] = False
     service_model = model.ServiceModel(self.model)
     operation_name = service_model.operation_model('OperationName')
     self.assertFalse(operation_name.deprecated)
示例#23
0
def test_missing_model_attribute_raises_exception(property_name):
    service_model = model.ServiceModel({'metadata': {'endpointPrefix': 'foo'}})
    with pytest.raises(model.UndefinedModelAttributeError):
        getattr(service_model, property_name)