Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 11
0
def get_operation_model_with_retries():
    service = model.ServiceModel(SERVICE_DESCRIPTION_WITH_RETRIES,
                                 service_name='my-service')
    return service.operation_model('TestOperation')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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))
Ejemplo n.º 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'))
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)