Remote scenario setup for e2e testing of django projects
Project description
Remote scenario setup for e2e testing of django projects
Documentation
The full documentation will be at https://django-remote-scenario.readthedocs.org.
Quickstart
Install django-remote-scenario:
pip install django-remote-scenario
Then add it to an exsiting django project:
INSTALLED_APPS = [ ... django_rs
You need to add django_rs urls to your project url file like this:
urlpatterns = patterns('', ... url(r'^drs/', include('django_rs.urls')), .. )
To create custom scenarios, just create a directory inside your app named “scenarios” , then add as many files as scenarios you want to implement and create a __init__.py file to import them. Inside each of those files, you need to implement a main() function setting up the models you want to create for the scenario, you could create them by hand or use something like django_dynamic_fixtures https://github.com/paulocheque/django-dynamic-fixture
Note: Your scenario is not limited to creating new models, you may also mock specific parts of the enviroment as well
Once everything is ready, start the server this way, this will enable the dynamic call of scenarios:
python manage.py rune2eserver initial_data.json
Note: You need to pass a initial fixture file with the barebones of your data.
it is also possible to pass a specific settings file, for testing purposes, in case you want to do the tests using a different database for example:
python manage.py rune2eserver initial_data.json --settings=demoproject.test_settings [fixture1 fixture2....] [--addrport ipaddress:port]
To start using it, just go to the following url:
http://127.0.0.1:8000/drs/[APPLICATION]/[SCENARIO]
after doing that the database will be populated with the data you provided in your scenario. Take into account that, everytime you call an scenario, all the other data in the database is erased, except for the one in your initial_data fixture files, wich are loaded again, and also the one you pass as a parameter when you call the command.
Inside this repository you will find a demo Django project preconfigured with a simple scenario that sets up four objects. Use it like this:
First run the server:
$ python manage.py rune2eserver initial_data.json --settings=demoproject.test_settings
Then go to your browser and setup a scenario:
http://127.0.0.1:8000/drs/demoapp/scenario_1
You may also pass a parameter to avoid flushing the database on a specific call:
http://127.0.0.1:8000/drs/demoapp/scenario_1/?flush=0
Later you could see the results on the following url:
http://127.0.0.1:8000/demoapp/
Experimental scenario listing has been added, and could be checked out by visting the root url for drs (on this case /drs/)
http://127.0.0.1:8000/drs/
Fake login:
If you want to avoid having to login, each time you try a new scenario, an experimental fake login has been added, you just have to add the following inside your custom test_settings file
DEFAULT_FAKE_USER_ID = 1 MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES) AUTHENTICATION_BACKENDS = ('django_rs.backends.FakeBackendAuth',) MIDDLEWARE_CLASSES.append('django_rs.backends.FakeMiddlewareAuth')
Note that the FAKE_USER_ID has to be an existent one, (you may provide this on a fixture)
Features
TODO
History
0.1.0 (2014-05-31)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-remote-scenario-0.2.7.tar.gz
.
File metadata
- Download URL: django-remote-scenario-0.2.7.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dea11bae34d8c65a780a1d38d5e0fe9dcc65e28d149381077643f77a0ea491e8 |
|
MD5 | 3a58fd06a5807f1d892db8fa9977b153 |
|
BLAKE2b-256 | 4fdfdad85fc198f7d0fa1a35ddc6adc2e061e34a7244bf064319c3f6e217efb8 |