mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Added tests for using attnames to assign OneToOne and Foreign Key fields.
This commit is contained in:
committed by
Mariusz Felisiak
parent
4b4e68a7a6
commit
619c9a4f49
@@ -205,6 +205,18 @@ class OneToOneTests(TestCase):
|
||||
# reverse cache has a value of None.
|
||||
p.undergroundbar = None
|
||||
|
||||
def test_assign_o2o_id_value(self):
|
||||
b = UndergroundBar.objects.create(place=self.p1)
|
||||
b.place_id = self.p2.pk
|
||||
b.save()
|
||||
self.assertEqual(b.place_id, self.p2.pk)
|
||||
self.assertFalse(UndergroundBar.place.is_cached(b))
|
||||
self.assertEqual(b.place, self.p2)
|
||||
self.assertTrue(UndergroundBar.place.is_cached(b))
|
||||
# Reassigning the same value doesn't clear a cached instance.
|
||||
b.place_id = self.p2.pk
|
||||
self.assertTrue(UndergroundBar.place.is_cached(b))
|
||||
|
||||
def test_related_object_cache(self):
|
||||
""" Regression test for #6886 (the related-object cache) """
|
||||
|
||||
|
||||
Reference in New Issue
Block a user