Skip to content

Latest commit

 

History

History

baseapp-e2e

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

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):

{
    "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

Install in your environment:

pip install 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