Skip to main content

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

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

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baseapp-e2e-0.1.tar.gz (8.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page