+ w2 = Work.objects.create(name="Work without notes", author=a2)
+ q2 = Quote.objects.create(text="Quote02, no tags", work=w2)
+ self.assertSequenceEqual(q2.tags.all(), [])
+
+ def test_all(self):
+ content = self.getPage('all/')
+ for a in Author.objects.all():
+ self.assertIn(a.name, content)
+ self.assertIn(a.notes, content)
+ for w in Work.objects.all():
+ self.assertIn(w.name, content)
+ self.assertIn(w.notes, content)
+ for q in Quote.objects.all():
+ self.assertIn(q.text, content)
+ self.assertIn(q.notes, content)
+
+ def test_random(self):
+ seen = {}
+ for q in Quote.objects.all():
+ seen[q.id] = False
+
+ # <a href="{% url 'quotes:onequote' quote.id %}">Permalink</a>
+ permalinkre = re.compile(r'([0-9]+).*Permalink')
+
+ for i in xrange(100):
+ content = self.getPage('random')
+ m = permalinkre.search(content)
+ self.assertIsNotNone(m, content)
+ quoteid = int(m.group(1))
+ self.assertIn(quoteid, seen)
+ seen[quoteid] = True
+ for q in Quote.objects.all():
+ self.assertTrue(seen[q.id])