BaseApp End-To-End Tests
Project description
BaseApp E2E
Usage
This project includes utilities for database initialization and seeding when performing End-To-End tests.
E2E Endpoints
E2EViewSet has a set of endpoints for managing the test data from the frontend E2E test client (usually from Cypress):
- POST
/load-data
- load data using Django's default serizlization format. Example payload:
{
"objects": [{
"model": "users.user",
"fields": {
"email": "abc@tsl.io",
// ...
}}, {
"model": "users.user",
"fields": {
"email": "def@tsl.io",
// ...
}
}]
}
- POST
/load-script
- load data through a script module that exists in the backend project repository. Example:
Set the SCRIPTS_PACKAGE
setting to a module path where the scripts are located:
E2E = {
"ENABLED": True,
"SCRIPTS_PACKAGE": "e2e.scripts",
}
Then add a python script on the defined module path, e.g.: <project-root>/e2e/scripts/users.py
. The script is expected to have a def load()
function that will be executed by the endpoint.
import tests.factories as f
def load():
f.UserFactory()
To request the script to be run use request format as:
{
"scripts": ["users"]
}
- POST
/flush-data
- remove the data from database using Django flush command - POST
/set-password
- set a password for an existing user. Example payload:
{
"user": <user id>,
"password": "1234"
}
Demo
There is a test project with a complete demo set up.
Installation
Add to requirements of yor project (replacing everything inside brackets):
baseapp-e2e @ git+https://github.com/silverlogic/baseapp-backend.git@v0.1#subdirectory=baseapp-e2e
Settings
Add the app to your project INSTALLED_APPS:
INSTALLED_APPS = [
...
"baseapp_e2e",
]
Add E2E settings to Django settings file of your application:
E2E = {
"ENABLED": True,
"SCRIPTS_PACKAGE": "e2e.scripts",
}
How to delevop
General development instructions can be found in main README
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 baseapp-e2e-0.1.tar.gz
.
File metadata
- Download URL: baseapp-e2e-0.1.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9959a4fa462e785178f57b0bbc0e218cb189f3b088015b1e4bc6890af795b08 |
|
MD5 | 0e874c579336b9b4faec02f29373a633 |
|
BLAKE2b-256 | 892de08944d5e25a9df0faf7f751759bc25f85261c0117ccedc412f2b28d5b6b |