summaryrefslogtreecommitdiff
path: root/tests/get_or_create
diff options
context:
space:
mode:
authorFrançois Freitag <francois.freitag@polyconseil.fr>2016-10-03 19:57:05 -0700
committerTim Graham <timograham@gmail.com>2016-10-04 10:10:39 -0400
commit1db1f74617ae0c7b100065117ed1d9ac19a6143a (patch)
treed101c3b8fea9513eae244a1674d0a00fb8c39feb /tests/get_or_create
parent040bd7c9387cfbf70a543c507b3b9eeb8f2725dc (diff)
downloaddjango-1db1f74617ae0c7b100065117ed1d9ac19a6143a.tar.gz
Refs #27118 -- Reallowed using pk in QuerySet.get/update_or_create().
Diffstat (limited to 'tests/get_or_create')
-rw-r--r--tests/get_or_create/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/get_or_create/tests.py b/tests/get_or_create/tests.py
index 8100c305b6..d727bdee5d 100644
--- a/tests/get_or_create/tests.py
+++ b/tests/get_or_create/tests.py
@@ -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.