Commits

Waldemar Kornewald  committed 728d298

Moved DB features to DatabaseFeatures instead of ops. Added little ModelForm test to make sure unique constraint doesn't test for pk__isnull

  • Participants
  • Parent commits 0130b7c

Comments (0)

Files changed (2)

                 logging.error("Failed to clear datastore: %s" % error)
 
 class DatabaseFeatures(BaseDatabaseFeatures):
-    pass
+    distinguishes_insert_from_update = False
+    supports_deleting_related_objects = False
+    supports_multi_table_inheritance = False
 
 class DatabaseOperations(BaseDatabaseOperations):
     query_backend = 'djangoappengine.db.backend.QueryBackend'
-    distinguish_insert_from_update = False
-    supports_deleting_related_objects = False
-    supports_multi_table_inheritance = False
 
     def quote_name(self, name):
         return name

File tests/backend.py

 from django.db import models
 from django.test import TestCase
 
+class A(models.Model):
+    value = models.IntegerField()
+
+class B(A):
+    value2 = models.IntegerField()
+
+class AbstractB(A):
+    value2 = models.IntegerField()
+    class Meta:
+        abstract = True
+
+class C(B):
+    value3 = models.IntegerField()
+
 class BackendTest(TestCase):
     def test_multi_table_inheritance(self):
-        class A(models.Model):
-            value = models.IntegerField()
-        class B(A):
-            value2 = models.IntegerField()
         self.assertRaises(ValueError, B.objects.count)
         self.assertRaises(ValueError, B.objects.all().get)
         self.assertRaises(ValueError, lambda: B.objects.all()[:10][0])
         self.assertRaises(ValueError, B(value=1, value2=2).save)
 
-        class AbstractB(A):
-            value2 = models.IntegerField()
+        self.assertRaises(ValueError, C(value=1, value2=2, value3=3).save)
+
+    def test_model_forms(self):
+        from django import forms
+        class F(forms.ModelForm):
             class Meta:
-                abstract = True
+                model = A
 
-        class C(B):
-            value3 = models.IntegerField()
-        self.assertRaises(ValueError, C(value=1, value2=2, value3=3).save)
+        F({'value': '3'}).save()