summaryrefslogtreecommitdiff
path: root/tests/modeltests/model_forms/tests.py
blob: 49ea314bc612c2bd7c02020133008dda32b40a65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from django.test import TestCase
from django import forms
from models import Category


class IncompleteCategoryForm(forms.ModelForm):
    """
    A form that replaces the model's url field with a custom one. This should
    prevent the model field's validation from being called.
    """
    url = forms.CharField(required=False)

    class Meta:
        fields = ('name', 'slug')
        model = Category

class ValidationTest(TestCase):
    def test_validates_with_replaced_field(self):
        form = IncompleteCategoryForm(data={'name': 'some name', 'slug': 'some-slug'})
        assert form.is_valid()