Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chairchandler/django-fields-testing
Package for testing fields in django models and regular classes.
https://github.com/chairchandler/django-fields-testing
django django-models model-testing orm-library pytest testing testing-library
Last synced: 4 days ago
JSON representation
Package for testing fields in django models and regular classes.
- Host: GitHub
- URL: https://github.com/chairchandler/django-fields-testing
- Owner: ChairChandler
- License: mit
- Created: 2024-10-20T20:31:15.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2024-10-21T16:16:43.000Z (30 days ago)
- Last Synced: 2024-10-22T14:37:36.213Z (29 days ago)
- Topics: django, django-models, model-testing, orm-library, pytest, testing, testing-library
- Language: Python
- Homepage:
- Size: 138 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Description
## Overview
Package allows to test django model fields, meta model fields and normal class fields by subclasing dedicated special classes and django test class.
Every single class created using subclassing API is dedicated to specified model field. Apart from basic
field information like name and type for specified model, we can also test if it was created with specified attributes. Attributes are predefined.Example:
```python
from django.test import SimpleTestCaseclass NameFieldTest(ModelFieldTest, SimpleTestCase):
model = User
field_name = 'name'
field_type = TextField
default = ''
primary_key = Trueclass UppercasedUsernameFieldTest(ClassFieldTest, SimpleTestCase):
klass = User
field_name = 'USERNAME_FIELD'
value = 'email'class ConstraintsFieldTest(MetaFieldTest, SimpleTestCase):
klass = User
field_name = 'constraints'
value = [
models.UniqueConstraint(
fields=['telephone_prefix', 'telephone_number'],
name='telephone_number_with_prefix_unique'
)
]
```Model field tests currently support the following attributes for fields:
- primary_key
- default
- verbose_name
- unique
- max_length
- validators
- help_text
- null
- blank## Source code
**src** directory contains files dedicated to one of the special field testing class.
## Testing
**tests** directory contains files dedicated to testing one of the special field testing class.
To run tests, run script **run_tests.sh** inside **scripts** directory. It will generates unit tests report and coverage report inside **reports** directory.
## Building
To build a package run **run_build.sh** inside **scripts** directory. It will generate **whl** package file inside **dist** directory.
## Installation
Being inside package base directory run
> pip install dist/.whl