def test_service_name_can_be_overriden(self): service_model = model.ServiceModel(self.model, service_name='myservice') self.assertEqual(service_model.service_name, 'myservice')
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')
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)
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)
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')
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)
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)
def test_name_from_service(self): service_model = model.ServiceModel(self.model) operation = service_model.operation_model('OperationName') self.assertEqual(operation.name, 'OperationName')
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)
def test_deprecated_absent(self): service_model = model.ServiceModel(self.model) operation_two = service_model.operation_model('OperationTwo') self.assertFalse(operation_two.deprecated)
def get_operation_model_with_retries(): service = model.ServiceModel(SERVICE_DESCRIPTION_WITH_RETRIES, service_name='my-service') return service.operation_model('TestOperation')
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)
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)
def test_operation_name_in_repr(self): service_model = model.ServiceModel(self.model) operation = service_model.operation_model('OperationName') self.assertIn('OperationName', repr(operation))
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'))
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')
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')
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')
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)
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)
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')
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)
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)