Mountebank
for honest Python developers
Title Text
http://www.mbtest.org/
Stubs
In-Process Stubs
HTTPretty
- Works great when it works
- Tests are fast
- Sharp edge cases
- Hard to debug when it doesn't work
- Not true integration tests
Out-of-Process Stubs
Python-Stub-Server
https://github.com/tarttelin/Python-Stub-Server
- Closer to being integration tests
- Relatively nice API for setting up stubs
- Spawns threads in the test harness
- Not a standalone server
- Problem with teardown
- Low project activity
Out-of-Process Stubs
Pretender
https://github.com/pretenders/pretenders
- A real OOP server built on bottle
- Manipulate stubs through HTTP client
- Always runs in foreground
- Stubbed service on the same port as the control service
-
Unreasonable default behaviour
- deletes stubs every few minutes
Mountebank
- Out of process stub server similar to pretenders written in NodeJS
- Simple HTTP API
- More flexible stub setup
- Multiple protocols (http, https, smtp, generic-tcp)
- Control service (imposter) can spawn stub services on different ports
- Better process handling (shutdown works better - see later slides)
- More active community and superb documentation
But But...
I don't want to require nodejs/npm/left-pad :)
to run my Python project
Yeeew..
Did you say Node?
In dubio, uti Docker[*]
Unofficial A-Team Motto
* Roughly translates to "When In Doubt, Use More Docker"
docker run -d
dev-docker.points.com:80/mountebank
- Based on alpine
- https://github.com/kevinjqiu/docker-mountebank/blob/master/Dockerfile
- No nodejs dependencies => project folder is clean
- Daemonization through docker => shutdown/cleanup works without our effort \o/
Demos
More Advanced Features
- Stub https or any TCP requests
- Define your own predicates using Javascript
- injectors - hook that can modify proxied responses
- Web UI for adding/testing stub definitions
References
Main site:
http://www.mbtest.org/
Points Project uses MB:
https://github.com/Points/bgt-reporting/blob/master/tests/stubs.py
Python Client Libraries
https://github.com/kevinjqiu/py-mountebank
https://github.com/aholyoke/mountebank-python
Mountebank
By Kevin Jing Qiu
Mountebank
- 1,261