def test_make_auto_deployable_no_swagger(self, LogicalIdGeneratorMock): prefix = "prefix" stage = MagicMock() deployment = ApiGatewayDeployment(logical_id=prefix) deployment.make_auto_deployable(stage, swagger=None) self.assertEquals(deployment.logical_id, prefix) self.assertEquals(deployment.Description, None) LogicalIdGeneratorMock.assert_not_called() stage.update_deployment_ref.assert_not_called()
def _construct_deployment(self, rest_api): """Constructs and returns the ApiGateway Deployment. :param model.apigateway.ApiGatewayRestApi rest_api: the RestApi for this Deployment :returns: the Deployment to which this SAM Api corresponds :rtype: model.apigateway.ApiGatewayDeployment """ deployment = ApiGatewayDeployment(self.logical_id + 'Deployment') deployment.RestApiId = rest_api.get_runtime_attr('rest_api_id') deployment.StageName = 'Stage' return deployment
def _construct_deployment(self, rest_api): """Constructs and returns the ApiGateway Deployment. :param model.apigateway.ApiGatewayRestApi rest_api: the RestApi for this Deployment :returns: the Deployment to which this SAM Api corresponds :rtype: model.apigateway.ApiGatewayDeployment """ deployment = ApiGatewayDeployment( self.logical_id + "Deployment", attributes=self.passthrough_resource_attributes ) deployment.RestApiId = rest_api.get_runtime_attr("rest_api_id") if not self.remove_extra_stage: deployment.StageName = "Stage" return deployment
def _construct_deployment(self, rest_api, open_api_version): """Constructs and returns the ApiGateway Deployment. :param model.apigateway.ApiGatewayRestApi rest_api: the RestApi for this Deployment :returns: the Deployment to which this SAM Api corresponds :rtype: model.apigateway.ApiGatewayDeployment """ deployment = ApiGatewayDeployment( self.logical_id + 'Deployment', attributes=self.passthrough_resource_attributes) deployment.RestApiId = rest_api.get_runtime_attr('rest_api_id') if not self.open_api_version: deployment.StageName = 'Stage' return deployment
def test_make_auto_deployable_with_swagger_dict(self, LogicalIdGeneratorMock): prefix = "prefix" generator_mock = LogicalIdGeneratorMock.return_value stage = MagicMock() id_val = "SomeLogicalId" full_hash = "127e3fb91142ab1ddc5f5446adb094442581a90d" generator_mock.gen.return_value = id_val generator_mock.get_hash.return_value = full_hash swagger = {"a": "b"} deployment = ApiGatewayDeployment(logical_id=prefix) deployment.make_auto_deployable(stage, swagger=swagger) self.assertEqual(deployment.logical_id, id_val) self.assertEqual(deployment.Description, "RestApi deployment id: {}".format(full_hash)) LogicalIdGeneratorMock.assert_called_once_with(prefix, str(swagger)) generator_mock.gen.assert_called_once_with() generator_mock.get_hash.assert_called_once_with(length=40) # getting full SHA stage.update_deployment_ref.assert_called_once_with(id_val)