Skip to main content

A Django app for specifying validation tests on data in your database.

Project description

https://badge.fury.io/py/django-data-tests.svg https://travis-ci.org/andrewbird2/django-data-tests.svg?branch=master https://codecov.io/gh/andrewbird2/django-data-tests/branch/master/graph/badge.svg

A Django app for specifying validation tests on data in your database.

Quickstart

Install Django Data Tests:

pip install django-data-tests

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'data_tests.apps.DataTestsConfig',
    ...
)

Add a data test to one of your existing models

from data_tests.registry import test_method
from django.db import models

class Cat(models.Model):
    ...

    def make_noise(self):
        return 'Miaow!'

    @test_method('Check the cat miaows appropriately')
    def check_cat_sound(self):
        noise = self.noise()
        if noise != 'Miaow!':
            return False, 'Cat made the wrong noise: %s' % noise
        else:
            return True

You can run your data tests with the management command

./manage.py rundatatests

Alternatively, run them whenever the object is saved in the admin

from django.contrib import admin
from data_tests.admin import DataTestsAdminMixin

class CatAdmin(DataTestsAdminMixin, admin.ModelAdmin):
    ...

History

0.1.0 (2019-11-18)

  • First release on PyPI.

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-data-tests-0.6.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_data_tests-0.6.0-py2.py3-none-any.whl (13.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-data-tests-0.6.0.tar.gz.

File metadata

  • Download URL: django-data-tests-0.6.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.9

File hashes

Hashes for django-data-tests-0.6.0.tar.gz
Algorithm Hash digest
SHA256 b1eaccc20fdb1b2db9c2ad0f921e0e81be2e43a50fddd0ce1920fa023189ab6b
MD5 0e9a2237cfcd0a1ada91bcbaff76c38c
BLAKE2b-256 c12179137ce3f04dbad18746c3ad95737baaa79d3cc791ad38b8a325e90eabd8

See more details on using hashes here.

File details

Details for the file django_data_tests-0.6.0-py2.py3-none-any.whl.

File metadata

  • Download URL: django_data_tests-0.6.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.9

File hashes

Hashes for django_data_tests-0.6.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 13fba5203429e7757e8669bb267b88175a18b03d0d538cfb66d5fc2beae95d55
MD5 4d8e2df9495741821bbb59bc0d889385
BLAKE2b-256 efb69480b8ef134b631b888016355afebf583bbb332ae8e68b2247500fb8bb3f

See more details on using hashes here.

Supported by

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