While a lambda is still processing (archive unpacking etc), the lambda state should be set to "Pending" (currently "Active") and invocations to that lambda should fail (currently, it can end up in a inconsistent state in this case, like lambdas being executed without layers).

Lambda state should reflect the current internal state, and invocations should fail if not active.
self.assertEqual(1, len(result))
    def test_delete_event_source_mapping(self):
        region = lambda_api.LambdaRegion.get()
        with self.app.test_request_context():
            region.event_source_mappings.append({"UUID": self.TEST_UUID})
            result = lambda_api.delete_event_source_mapping(self.TEST_UUID)
            self.assertEqual(self.TEST_UUID, json.loads(result.get_data()).get("UUID"))
            self.assertEqual(0, len(region.event_source_mappings))
    def test_invoke_RETURNS_415_WHEN_not_json_input(self):
        with self.app.test_request_context() as context:
            context.request._cached_data = "~notjsonrequest~"
            response = lambda_api.invoke_function(self.FUNCTION_NAME)
            self.assertEqual("415 UNSUPPORTED MEDIA TYPE", response.status)
    def _request_response(self, context):
        context.request._cached_data = "{}"
        context.request.args = {"Qualifier": "$LATEST"}
        context.request.environ["HTTP_X_AMZ_INVOCATION_TYPE"] = "RequestResponse"
        self._create_function(self.FUNCTION_NAME)
    @mock.patch("localstack.services.awslambda.lambda_api.run_lambda")
    def test_invoke_plain_text_response(self, mock_run_lambda):
        with self.app.test_request_context() as context:
            self._request_response(context)
            mock_run_lambda.return_value = "~notjsonresponse~"
            response = lambda_api.invoke_function(self.FUNCTION_NAME)
            self.assertEqual("~notjsonresponse~", response[0])
            self.assertEqual(200, response[1])
            headers = response[2]
            self.assertEqual("text/plain", headers["Content-Type"])
    @mock.patch("localstack.services.awslambda.lambda_api.run_lambda")
    def test_invoke_empty_plain_text_response(self, mock_run_lambda):