Skip to main content

An Introduction to Pretenders

The pretenders project creates flexible fakes for external network services. These external services can be faked by setting pre-canned answers, defining expectations, or just querying them on received data after [test] execution.

They are loosely designed along the pattern of Record/Replay/Verify.

Python Compatibility

The server side of Pretenders is written in Python3:

  • Because we firmly believe all new projects should use Python3, unless there are very compelling reasons against it.

  • Because since these will be run as standalone servers, compatibility is not such an issue

In the cases we implement a client, we will be making this runnable in Python 3.x and Python 2.6/2.7.

Mocked Servers Available

Pretenders currently supports the mocking of HTTP and SMTP servers.

Future services we are considering to support include AMQP and ssh.

These represent the vast majority of the services that the software we write interacts with.

Some example use cases include:

  • Mocking external HTTP-based APIs at the wire level in module integration tests

  • Facilitating the manual testing and debugging of front-end Ajax code where the back-end has not been developed yet

  • Writing fully automated tests for any system that sends email, and where we want to easily verify outgoing mails

Pretenders provides a unified RESTful API to verify the interactions of our code with external services, regardless of the service protocol.

pretenders.client.http - HTTP server

Typical usage is to mock RESTful/SOAP APIs of external services.

This will normally require pre-programming the service with responses, and enquiring the service later about received requests. This can be done with specialised assertions / matchers, or by setting expectations and verifying fulfilment of such expectations.

The pre-programming step may be done by using specific proprietary HTTP headers, or by using an alternative HTTP port to the one used for mocking.

For example usage see the documentation.

Implementation is based on the bottle web microframework.

One of our goals will be that the wire protocol is simple enough that you do not need any specialised client. That said, we will be providing client libraries (at least one in Python) to simplify interacting with the server, and to provide a comfortable API to use in tests.

Getting Help

For discussions about the usage, development, and future of pretenders, please join the pretenders mailing list.

Documentation

Full documentation of the project can be found here:

http://pretenders.readthedocs.org/

Contributing

Pretenders welcomes contributions in any form - be it pull requests, adding an issue or feedback via github or sending a message on the pretenders mailing list so don’t be shy!

We have the following branching convention:

  • master: This should look exactly like the latest release.

  • develop: This is where ongoing work lands, only being merged into master at release point.

In order to contribute, fork the repo in github and branch from the develop branch. Create your PRs into develop in the main repo.

Running the tests

build.sh runs the full suite of tests, as well as building the sphinx docs and checking for pep8 errors.

Metadata

Release files for pretend_extended 2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pretend_extended 2.1
File Size Uploaded
pretend_extended-2.1.zip 55.6 kB Details

Release files / pretend_extended-2.1.zip

Download URL pretend_extended-2.1.zip
Size 55.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a8defb6d31a3f6363846691f6b2e87e4aade99f1c780c6a64980f55b01a59781
BLAKE2b-256 checksum
How to use checksums
9fe4a5cf6a52c7855bf8a524885264353245a0bf39b1e3d1426b505bdbeb7314
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

2.1 This release

1 release file

2.0

1 release file

1.2.8

1 release file

1.2.7

1 release file

1.2.6

1 release file

1.2.5

1 release file

1.2.4

1 release file

1.2.3.2

1 release file

1.2.3.1

1 release file

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page