Git Product home page Git Product logo

django-replay's Introduction

Django Replay

Django Replay is an Apache2 licensed Django application that records and replays web requests.

Features

  • Record requests/responses as easy as "runserver"
  • Test scenarios by replaying requests with validators
  • Template requests/responses for dynamic identifiers
  • Tested on Python 3.7, 3.8, 3.9, 3.10
  • Tested on Django 3.2 LTS and Django 4.0

image

image

Quickstart

Installing Django Replay is simple with pip:

$ pip install django-replay

Add replay to the INSTALLED_APPS in settings.py like:

INSTALLED_APPS += ['replay']

Then migrate the database like:

$ python manage.py migrate

Django Replay provides two management commands:

  1. replayrecord -- like "runserver" but request/responses are recorded.
  2. replaytest -- runs the scenarios with actions and validators.

Django Replay also provides three models:

  1. Scenario -- ordered list of actions.
  2. Action -- recorded request/response template.
  3. Validator -- regular expression for response validation.

These models can be edited in the admin.

Tutorial

To get started, follow the Quickstart and then record some actions:

$ python manage.py replayrecord

Navigate to http://127.0.0.1:8000/ and use the web app as normal. Once the actions are recorded run CTRL-C to stop the command.

Now create some scenarios in the admin:

$ python manage.py runserver

TODO: Insert screenshots of creating scenarios.

The scenarios can be tested manually using:

$ python manage.py replaytest

Remember to clear the content of the actions. Now the tests can be saved in a fixture.

$ python manage.py dumpdata --indent 4 replay > replay.json

And the scenarios can be integrated with Django's test framework like so:

from django.test import TestCase
from replay.utils import test_scenarios

 class ReplayTestCase(TestCase):
     fixtures = ['path/to/replay.json']

     def test_scenarios(self):
         test_scenarios()

Templates and Validators

TODO: Describe templating syntax for requests

TODO: Describe regular expression features for validators

Reference and Indices

Django Replay License

Copyright 2017-2022 Grant Jenks

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

django-replay's People

Contributors

grantjenks avatar jaap3 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jaap3 liliai

django-replay's Issues

Write the Docs

The title "Django Replay is an Apache2 licensed Django application that records and replays web requests." is exactly what I am looking for.

But now I don't know how to continue.

Please provide some docs.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.