Changeset 8185 for django/trunk/tests/regressiontests/one_to_one_regress
- Timestamp:
- 08/01/08 18:16:59 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/tests/regressiontests/one_to_one_regress/models.py
r7574 r8185 23 23 return u"%s the bar" % self.place.name 24 24 25 class UndergroundBar(models.Model): 26 place = models.OneToOneField(Place, null=True) 27 serves_cocktails = models.BooleanField() 28 25 29 class Favorites(models.Model): 26 30 name = models.CharField(max_length = 50) … … 43 47 [<Restaurant: Demon Dogs the restaurant>] 44 48 45 # Regression test for #7173: Check that the name of the cache for the 49 # Regression test for #7173: Check that the name of the cache for the 46 50 # reverse object is correct. 47 51 >>> b = Bar(place=p1, serves_cocktails=False) … … 54 58 # 55 59 # Regression test for #6886 (the related-object cache) 56 # 60 # 57 61 58 62 # Look up the objects again so that we get "fresh" objects … … 77 81 True 78 82 83 # Assigning None succeeds if field is null=True. 84 >>> ug_bar = UndergroundBar.objects.create(place=p, serves_cocktails=False) 85 >>> ug_bar.place = None 86 >>> ug_bar.place is None 87 True 88 79 89 # Assigning None fails: Place.restaurant is null=False 80 90 >>> p.restaurant = None … … 89 99 ValueError: Cannot assign "<Place: Demon Dogs the place>": "Place.restaurant" must be a "Restaurant" instance. 90 100 101 # Creation using keyword argument should cache the related object. 102 >>> p = Place.objects.get(name="Demon Dogs") 103 >>> r = Restaurant(place=p) 104 >>> r.place is p 105 True 106 107 # Creation using keyword argument and unsaved related instance (#8070). 108 >>> p = Place() 109 >>> r = Restaurant(place=p) 110 >>> r.place is p 111 True 112 113 # Creation using attname keyword argument and an id will cause the related 114 # object to be fetched. 115 >>> p = Place.objects.get(name="Demon Dogs") 116 >>> r = Restaurant(place_id=p.id) 117 >>> r.place is p 118 False 119 >>> r.place == p 120 True 121 91 122 """}
