/tests/modeltests/mutually_referential/tests.py

https://code.google.com/p/mango-py/ · Python · 20 lines · 11 code · 4 blank · 5 comment · 0 complexity · 916c06ab823ce3feaa8a454798d73648 MD5 · raw file

  1. from django.test import TestCase
  2. from models import Parent, Child
  3. class MutuallyReferentialTests(TestCase):
  4. def test_mutually_referential(self):
  5. # Create a Parent
  6. q = Parent(name='Elizabeth')
  7. q.save()
  8. # Create some children
  9. c = q.child_set.create(name='Charles')
  10. e = q.child_set.create(name='Edward')
  11. # Set the best child
  12. # No assertion require here; if basic assignment and
  13. # deletion works, the test passes.
  14. q.bestchild = c
  15. q.save()
  16. q.delete()