Skip to content

pactflow/example-consumer-python-sns

Repository files navigation

Example Python AWS SNS Consumer

Build Status

Can I deploy Status

Pact Status (latest pact)

Pact Status (prod/prod pact)

This is an example of a Python AWS SNS consumer that uses Pact, Pactflow and GitHub Actions to ensure that it is compatible with the expectations its consumers have of it.

All examples in the series example-consumer-<language>-sns provide the same functionality to be easily comparable across languages. As such, please refer to [https://docs.pactflow.io/docs/examples/aws/sns/consumer/](AWS SNS Consumer Examples) to avoid unnecessary duplication of details here.

Language specific sections which differ from the canonical example only can be found below.

How to write tests?

We recommend that you split the code that is responsible for handling the protocol specific things - in this case the lambda and SNS input - and the piece of code that actually handles the payload.

You're probably familiar with layered architectures such as Ports and Adaptors (also referred to as a Hexagonal architecture). Following a modular architecture will allow you to do this much more easily:

Code Modularity

This code base is setup with this modularity in mind:

The target of our consumer pact test is the Event Service, which is responsible for consuming a Product update event, and persisting it to a database (the Repository).

See also:

Usage

Testing

  • Run the unit tests: make test
  • Run a (local) lambda integration test: make integration

About

An SNS message consumer, written in Python, using Pact

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •