Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Smithy Python Protocol Test

This package generates and runs protocol tests for all supported protocols. Protocol tests are defined in the Smithy model itself using traits, and are generated along with the client. These test the actual functionality of the generated client and protocol implementation using expected inputs and outputs. The tests are generated by HttpProtocolTestGenerator .

For AWS protocols, these tests are defined here .

To run these tests, run make test-protocols from the repository root, ensuring that you have a Python virtual environment active.

When should I change this package?

This package should only be changed when support for a new protocol is initially introduced.

How can I add new protocol tests to an exiting protocol?

To add new protocol tests, the source protocol test package must be updated. For example, AWS protocol tests must be defined in the smithy-aws-protocol-tests package. After a new test case is added to the Smithy model, publish the change locally by running ./gradlew build publishToMavenLocal. Make sure that the version range of the dependency here contains the version of the protocol test package you are building.

How can I add protocol tests for a new protocol?

First, add a dependency on the package that contains the tests for the protocol. For AWS protocols, that already exists. Next, add a new projection in smithy-build.json for each service that has tests for the protocol. For example:

{
    "version": "1.0",
    "projections": {
        "rest-json-1": {
            "transforms": [{
                "name": "includeServices",
                "args": {
                    "services": ["aws.protocoltests.restjson#RestJson"]
                }
            }],
            "plugins": {
                "python-client-codegen": {
                    "service": "aws.protocoltests.restjson#RestJson",
                    "module": "restjson",
                    "moduleVersion": "0.0.1"
                }
            }
        },
        "my-new-protocol": {
            "transforms": [{
                "name": "includeServices",
                "args": {
                    "services": ["com.example#MyNewProtocolTestService"]
                }
            }],
            "plugins": {
                "python-client-codegen": {
                    "service": "com.example#MyNewProtocolTestService",
                    "module": "mynewprotocol",
                    "moduleVersion": "0.0.1"
                }
            }
        }
    }
}