Skip to main content

Package with new powerful TestCases and Assets to test django application fast. TDD is supported

Project description

Django DRY Tests

Package with new powerful TestCases and Assets to test django application fast. TDD is supported


Workflows

Tests Pylint

Package

Version Development Status Python version License Wheel

Support

Documentation Discussions Issues

Downloads

Day Downloads Week Downloads Month Downloads All Downloads

Languages

Languages Top Language

Development

Release date Last Commit Issues Closed Issues Pull Requests Closed Pull Requests Discussions

Repository Stats

Stars Contributors Forks


Menu

Mission

The mission of the Django DRY Tests to design and develop open source python package to test django application

  • fast
  • with minimal code duplication
  • with the ability to use TDD easily
  • simple and comfortable

Open Source Project

This is the open source project with MIT license. Be free to use, fork, clone and contribute.

Features

  • Special Request and Response classes to simple set test data
  • Special SimpleTestCase class with:
    • assertTrueResponse(self, current_response, true_response) - Main assert to compare real response with expected
    • assertResponsesAreTrue(self, response_pairs) - Compare many responses
    • Other more simple asserts (assertStatusCode, assertRedirectUrl, assertValueInContext, assertContextValues, assertContentValues)
  • Special TestCase class. Similar with SimpleTestCase but with testing database (Not ready yet)

Requirements

  • Django==4 (Lower versions haven't been tested)

Development Status

  • django-dry-tests
  • v0.1.0
  • 3 - Alpha

Package available on PyPi

Install

with pip

pip install django-dry-tests

from release page

Download source code from GitHub Releases page

clone from GitHub

git clone https://github.com/quillcraftsman/django-dry-tests.git
make install

Quickstart

For example, you need to test some view like this:

def index_view(request):
    if request.method == 'GET':
        context = {
            'title': 'Title'
        }
        return render(request, 'demo/index.html', context)

    name = request.POST.get('name', None)
    if name is not None:
        Simple.objects.create(name=name)
    return HttpResponseRedirect('/')

And you want to check:

  • GET response status code
  • GET response context data
  • GET response some html data
  • POST response status code
  • POST response redirect url
  • POST response save object to database (Not implemented yet)

Let`s see the tests code:

from dry_tests import (
    Request,
    TrueResponse as Response,
    SimpleTestCase,
    POST,
)


class ViewTestCase(SimpleTestCase):

    def test_main(self):
        data = [
            # Multy parameters GET
            {
                'request': Request(url='/'),
                'response': Response(
                    status_code=200,
                    in_context='title',
                    context_values={'title': 'Title'},
                    content_values=['Title'],
                ),
            },
            # Multy parameters POST
            {
                'request': Request(url='/', method=POST),
                'response': Response(
                    status_code=302,
                    redirect_url='/',
                ),
            },
        ]
        for item in data:
            request = item['request']
            true_response = item['response']
            current_response = request.get_url_response(self.client)
            self.assertTrueResponse(current_response, true_response)

That's all this simple test cover all your test tasks with (assertTrueResponse)

Contributing

You are welcome! To easy start please check:

Project details


Download files

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

Source Distribution

django-dry-tests-0.2.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

django_dry_tests-0.2.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file django-dry-tests-0.2.1.tar.gz.

File metadata

  • Download URL: django-dry-tests-0.2.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for django-dry-tests-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e04a5451acb52e4c4135f912d4f69ade09e2baf068af9bf70697361aa0be5d68
MD5 d965dd6b5136089c0b57a5b101b3c259
BLAKE2b-256 5b561f20c6eeeadc813c0d834ae20b975240688dd999f76ecd809dafdf170ea5

See more details on using hashes here.

Provenance

File details

Details for the file django_dry_tests-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_dry_tests-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8186e42e9a852271822e3397acd3a63b5207978ae865eb7bc419c09a095a4b9f
MD5 c931a78b58de9c4abb11b99a676ef111
BLAKE2b-256 d0e6f1efbfeecb5b627fb6f0a5c61c01f66716e6aea9949bcf596aae2c807e95

See more details on using hashes here.

Provenance

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