- self.assertTrue(q.text in content, content)
- self.assertTrue(q.notes in content, content)
+ 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 range(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])