A Django app for specifying validation tests on data in your database.
Project description
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)
Built Distribution
Close
Hashes for django_data_tests-0.6.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13fba5203429e7757e8669bb267b88175a18b03d0d538cfb66d5fc2beae95d55 |
|
MD5 | 4d8e2df9495741821bbb59bc0d889385 |
|
BLAKE2b-256 | efb69480b8ef134b631b888016355afebf583bbb332ae8e68b2247500fb8bb3f |