mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Added tests for using attnames to assign OneToOne and Foreign Key fields.
This commit is contained in:
parent
4b4e68a7a6
commit
619c9a4f49
2 changed files with 28 additions and 0 deletions
|
@ -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) """
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue