-
Notifications
You must be signed in to change notification settings - Fork 175
Notes on testing
The PyOWM has a strong focus on testing: we want it to be an open source project with industrial quality!
Unit tests aim to test the SW API of each class/module.
We make use of monkey patching (which is more convenient than mocking because Python is a dynamically typed) whenever there is the need to test the behavior of a SW component which is bound to an external SW entity/system (ie: the parts of the PyOWM library that call the real PyOWM web API via HTTP).
The default unit testing environment is Python's unittest: simple and clean enough, so no additional dependencies are needed.
Unit tests can be easily run using Tox along with py.test.
Running:
$ tox
triggers unit tests execution on all Python platfoms that are supported by PyOWM.
Also, unit tests can be run with:
$ pythonX.Y setup.py test -s tests.unit
Export your API Key as an environment variable named OWM_API_KEY
:
$ export OWM_API_KEY='<your-api-key>'
and then you can run the integration tests with:
$ cd tests/integration
$ tox
or - on Linux - use the test runner:
$ cd scripts
$ bash run_integration_tests.sh
Please note that depending on your subscription type some of the tests may be neglected, eg: if you have a free subscription tier, the test cases that invoke the OWM API to get historical weather data will fail as these data can only be retrieved using a paid account.
A Docker image is available for developing/testing PyOWM.
PyOWM is continuously built with Travis-CI CI builds every time a Git push and a Github pull request are issued.
Code coverage is checked on each CI build with Coveralls.io