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.

Files for django-data-tests, version 0.6.0
Filename, size File type Python version Upload date Hashes
Filename, size django_data_tests-0.6.0-py2.py3-none-any.whl (13.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-data-tests-0.6.0.tar.gz (10.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page