Unverified Commit c76e73a7 authored by Matteo Bigoi's avatar Matteo Bigoi Committed by GitHub
Browse files

Disable protocol tests for python until we add all the testing modules (#2501)

* Disable protocol tests for python until we add all the testing modules

* Generate operation ser/de in the correct module
parent db76db93
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line

/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
@@ -103,11 +102,15 @@ class PythonServerCodegenVisitor(
        )

        // Override `codegenContext` which carries the various symbol providers.
        val moduleDocProvider = codegenDecorator.moduleDocumentationCustomization(
            codegenContext,
            PythonServerModuleDocProvider(ServerModuleDocProvider(codegenContext)),
        )
        codegenContext =
            ServerCodegenContext(
                model,
                serverSymbolProviders.symbolProvider,
                null,
                moduleDocProvider,
                service,
                protocol,
                settings,
@@ -117,13 +120,6 @@ class PythonServerCodegenVisitor(
                serverSymbolProviders.pubCrateConstrainedShapeSymbolProvider,
            )

        codegenContext = codegenContext.copy(
            moduleDocProvider = codegenDecorator.moduleDocumentationCustomization(
                codegenContext,
                PythonServerModuleDocProvider(ServerModuleDocProvider(codegenContext)),
            ),
        )

        // Override `rustCrate` which carries the symbolProvider.
        rustCrate = RustCrate(
            context.fileManifest,
@@ -214,6 +210,10 @@ class PythonServerCodegenVisitor(
        }
    }

    override fun protocolTests() {
        logger.warning("[python-server-codegen] Protocol tests are disabled for this language")
    }

    /**
     * Generate service-specific code for the model:
     * - Serializers
+18 −3
Original line number Diff line number Diff line
@@ -556,6 +556,15 @@ open class ServerCodegenVisitor(
        }
    }

    /**
     * Generate protocol tests. This method can be overridden by other languages such has Python.
     */
    open fun protocolTests() {
        rustCrate.withModule(ServerRustModule.Operation) {
            ServerProtocolTestGenerator(codegenContext, protocolGeneratorFactory.support(), protocolGenerator).render(this)
        }
    }

    /**
     * Generate service-specific code for the model:
     * - Serializers
@@ -583,9 +592,7 @@ open class ServerCodegenVisitor(
        }

        // Generate protocol tests
        rustCrate.withModule(ServerRustModule.Operation) {
            ServerProtocolTestGenerator(codegenContext, protocolGeneratorFactory.support(), protocolGenerator).render(this)
        }
        protocolTests()

        // Generate service module
        rustCrate.withModule(ServerRustModule.Service) {
@@ -598,17 +605,25 @@ open class ServerCodegenVisitor(

    /**
     * For each operation shape generate:
     *  - Operations ser/de
     *  - Errors via `ServerOperationErrorGenerator`
     *  - OperationShapes via `ServerOperationGenerator`
     */
    override fun operationShape(shape: OperationShape) {
        // Generate errors.
        rustCrate.withModule(ServerRustModule.Error) {
            ServerOperationErrorGenerator(model, codegenContext.symbolProvider, shape).render(this)
        }

        // Generate operation shapes.
        rustCrate.withModule(ServerRustModule.OperationShape) {
            ServerOperationGenerator(shape, codegenContext).render(this)
        }

        // Generate operations ser/de.
        rustCrate.withModule(ServerRustModule.Operation) {
            protocolGenerator.renderOperation(this, shape)
        }
    }

    override fun blobShape(shape: BlobShape) {
+0 −1
Original line number Diff line number Diff line
@@ -138,7 +138,6 @@ class ServerProtocolTestGenerator(

    fun render(writer: RustWriter) {
        for (operation in operations) {
            protocolGenerator.renderOperation(writer, operation)
            renderOperationTestCases(operation, writer)
        }
    }