diff --git a/tests/regressiontests/forms/models.py b/tests/regressiontests/forms/models.py
index f4f8607..0f55170 100644
a
|
b
|
|
1 | 1 | from django.db import models |
2 | 2 | |
3 | | class BoundaryModel(models.Model): |
| 3 | class BoundaryModel(models.Model): |
4 | 4 | positive_integer = models.PositiveIntegerField(null=True, blank=True) |
5 | | |
| 5 | |
| 6 | class ForeignKeyModel(models.Model): |
| 7 | foreign_key = models.ForeignKey('self', null=True, blank=True) |
| 8 | |
6 | 9 | __test__ = {'API_TESTS': """ |
7 | 10 | >>> from django.newforms import form_for_model |
8 | 11 | |
9 | 12 | # Boundary conditions on a PostitiveIntegerField ######################### |
10 | | >>> BoundaryForm = form_for_model(BoundaryModel) |
11 | | >>> f = BoundaryForm({'positive_integer':100}) |
12 | | >>> f.is_valid() |
| 13 | >>> BoundaryForm = form_for_model(BoundaryModel) |
| 14 | >>> f = BoundaryForm({'positive_integer':100}) |
| 15 | >>> f.is_valid() |
13 | 16 | True |
14 | | >>> f = BoundaryForm({'positive_integer':0}) |
15 | | >>> f.is_valid() |
| 17 | >>> f = BoundaryForm({'positive_integer':0}) |
| 18 | >>> f.is_valid() |
16 | 19 | True |
17 | | >>> f = BoundaryForm({'positive_integer':-100}) |
18 | | >>> f.is_valid() |
| 20 | >>> f = BoundaryForm({'positive_integer':-100}) |
| 21 | >>> f.is_valid() |
19 | 22 | False |
20 | 23 | |
21 | | """} |
22 | | No newline at end of file |
| 24 | >>> from django.newforms import form_for_instance |
| 25 | >>> fk1 = ForeignKeyModel() |
| 26 | >>> fk1.save() |
| 27 | >>> fk2 = ForeignKeyModel(foreign_key=fk1) |
| 28 | >>> fk2.save() |
| 29 | >>> fk2.foreign_key == fk1 |
| 30 | True |
| 31 | >>> Form = form_for_instance(fk1, formfield_callback=lambda f, initial: f.formfield(initial=initial)) |
| 32 | >>> f = Form() |
| 33 | >>> f.is_valid() |
| 34 | False |
| 35 | >>> f = Form({'foreign_key': fk1.pk}) |
| 36 | >>> f.is_valid() |
| 37 | True |
| 38 | >>> f.errors |
| 39 | {} |
| 40 | """} |