=== modified file 'tests/modeltests/force_insert_update/models.py'
|
|
|
|
| 3 | 3 | automatic behaviour). |
| 4 | 4 | """ |
| 5 | 5 | from django.db import models, transaction, IntegrityError |
| | 6 | from django.test import TestCase |
| 6 | 7 | |
| 7 | 8 | class Counter(models.Model): |
| 8 | | name = models.CharField(max_length = 10) |
| | 9 | name = models.CharField(max_length=10) |
| 9 | 10 | value = models.IntegerField() |
| 10 | 11 | |
| | 12 | class ProxyCounter(Counter): |
| | 13 | class Meta: |
| | 14 | proxy = True |
| | 15 | |
| | 16 | class SubCounter(Counter): |
| | 17 | pass |
| | 18 | |
| 11 | 19 | class WithCustomPK(models.Model): |
| 12 | 20 | name = models.IntegerField(primary_key=True) |
| 13 | 21 | value = models.IntegerField() |
| 14 | 22 | |
| | 23 | class InheritanceTests(TestCase): |
| | 24 | def test_force_update_on_proxy_model(self): |
| | 25 | a = ProxyCounter(name="count", value=1) |
| | 26 | a.save() |
| | 27 | a.save(force_update=True) |
| | 28 | |
| | 29 | def test_force_update_on_inherited_model_without_fields(self): |
| | 30 | ''' |
| | 31 | Issue 13864: force_update fails on subclassed models, if they don't |
| | 32 | specify custom fields. |
| | 33 | ''' |
| | 34 | a = SubCounter(name="count", value=1) |
| | 35 | a.save() |
| | 36 | a.save(force_update=True) |
| | 37 | |
| 15 | 38 | __test__ = {"API_TESTS": """ |
| 16 | 39 | >>> c = Counter.objects.create(name="one", value=1) |
| 17 | 40 | |