|
@@ -71,6 +71,12 @@ class GetOrCreateTests(TestCase):
|
|
|
with self.assertRaises(IntegrityError):
|
|
|
Person.objects.get_or_create(first_name="Tom", last_name="Smith")
|
|
|
|
|
|
+ def test_get_or_create_with_pk_property(self):
|
|
|
+ """
|
|
|
+ Using the pk property of a model is allowed.
|
|
|
+ """
|
|
|
+ Thing.objects.get_or_create(pk=1)
|
|
|
+
|
|
|
def test_get_or_create_on_related_manager(self):
|
|
|
p = Publisher.objects.create(name="Acme Publishing")
|
|
|
# Create a book through the publisher.
|
|
@@ -324,6 +330,12 @@ class UpdateOrCreateTests(TestCase):
|
|
|
ManualPrimaryKeyTest.objects.update_or_create(id=1, data="Different")
|
|
|
self.assertEqual(ManualPrimaryKeyTest.objects.get(id=1).data, "Original")
|
|
|
|
|
|
+ def test_with_pk_property(self):
|
|
|
+ """
|
|
|
+ Using the pk property of a model is allowed.
|
|
|
+ """
|
|
|
+ Thing.objects.update_or_create(pk=1)
|
|
|
+
|
|
|
def test_error_contains_full_traceback(self):
|
|
|
"""
|
|
|
update_or_create should raise IntegrityErrors with the full traceback.
|