Skip to main content
https://badge.fury.io/py/django-remote-scenario.png https://travis-ci.org/skalanux/django-remote-scenario.png?branch=master https://coveralls.io/repos/skalanux/django-remote-scenario/badge.png?branch=master

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 existing django project:

INSTALLED_APPS = [
...
django_rs

Inside your settings file you also need to add the following:

SETTINGS_FILE_PATH = __file__

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 so it becomes a module . 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

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 (but not mandatory) 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]

You might also use you existing database to load scenarios on top of it with the “–skip-test-db” or “-t” modifier:

python manage.py rune2eserver -t initial_data.json

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/

Mocking

It is possible to mock parts of your backend between scenarios calls. You need to add a new directory inside the scenarios directory and name ir ‘mocks’, then, again, add as many mocks as you want to implement and create a __init__.py so it becomes a module . Inside each of those files. You can apply as many mocks as you want and deactivate them selectibly. Pay special atention to the order this mocks are applied, as it may affect their internal behaviour.

To apply a mock just go to the following URL (assumming a file named mock_1 inside demoapp/mocks

http://127.0.0.1:8000/drs/demoapp/mocks/mock_1?activate=1

To remove the mock:

http://127.0.0.1:8000/drs/demoapp/mocks/mock_1?activate=0

An example of a mock can be found inside the test application

Browseable interface

Experimental scenario and mocking browseable interface could be used to apply mocks and load scenarios by visting the root url for drs (on this case /drs/)

http://127.0.0.1:8000/drs/

Features

  • TODO

History

0.1.0 (2014-05-31)

  • First release on PyPI.

Release files for django-remote-scenario 0.3.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 django-remote-scenario 0.3.1
File Size Uploaded
django-remote-scenario-0.3.1.tar.gz 72.7 kB Details

Release files / django-remote-scenario-0.3.1.tar.gz

Download URL django-remote-scenario-0.3.1.tar.gz
Size 72.7 kB
Tags Source
SHA-256 checksum
How to use checksums
14343c4213fd1a90e82726fe7ffcba1f2816fa6a4f8c99c181551c2db93e86c0
BLAKE2b-256 checksum
How to use checksums
aaac9b01d3d037bad300a9c1128a4aad1e3a0d136ec8ecf33b24442d91c04752
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.1 This release

1 release file

0.3.0

1 release file

0.2.8

1 release file

0.2.7

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.2

0.2.1

0.2.0

1 release file

0.1.0

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