Ticket #18638: 18638-test.patch

File 18638-test.patch, 1.1 KB (added by David Hatch, 12 years ago)

test case

  • tests/regressiontests/one_to_one_regress/tests.py

    ---
     tests/regressiontests/one_to_one_regress/tests.py | 17 +++++++++++++++++
     1 file changed, 17 insertions(+)
    
    diff --git a/tests/regressiontests/one_to_one_regress/tests.py b/tests/regressiontests/one_to_one_regress/tests.py
    index eced885..fe23ffe 100644
    a b class OneToOneRegressionTests(TestCase):  
    202202        with self.assertNumQueries(0):
    203203            with self.assertRaises(UndergroundBar.DoesNotExist):
    204204                self.p1.undergroundbar
     205   
     206    def test_reverse_one_to_one_save(self):
     207        """
     208            Test that a one-to-one relation is saved to the db
     209            when it is accessed from the reverse side.
     210        """
     211       
     212        p = self.p1
     213        b = UndergroundBar(serves_cocktails=False)
     214        p.undergroundbar = b
     215        p.save()
     216       
     217        # Reload p1 from the db
     218        place = Place.objects.get(pk=p.pk)
     219        # Ensure that place.underground bar == b
     220        self.assertEqual(place.undergroundbar, b)
     221       
     222 No newline at end of file
Back to Top