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

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

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