title: Django Testing: How to stub that model.ForeignKey property?
body: <p>I have a model in django that has a foreign key to another model, and during unit testing I want to avoid tight-coupling of the two models and create a stub for the other model that will return different values each time.</p>
  
  <p>Contrived example:</p>
  
  <pre><code>class Moon(models.Model):
      def phase(self):
         # some extremely complex code
  
  class Wolf(models.Model):
      moon = models.ForeignKey(Moon)
      mood = models.CharField()
  
      def update_mood(self):
          if (self.moon.phase == 'new moon'):
              self.mood = "good"
          if (self.moon.phase == 'waxing crescent'):
              self.mood = "hopefull"
          ...
  </code></pre>
  
  <p>Example for the above:</p>
  
  <pre><code>w = Wolf()
  m = Moon()
  # m.phase = 'new moon'
  w.moon = m
  w.update_mood()
  w.mood   # 'good'
  </code></pre>
  
  <p>Now I want to test the Wolf().moon property after I do an update_mood() call, without actually touching the Moon model at all - because its a very complex model that goes out into all kinds of external systems to figure out its phase.</p>
  
  <p>Usually I would use monkey-patching for this, but since .mood is a property ... I can't really assign to it in a monkey-patching way.</p>
  
  <p>Help.</p>