X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=quotes%2Ftests.py;h=36dcc1d1cd1aa3d7cd84f40ad40d0a3e1571b424;hb=060697325678491b635afba501ffae7abe09c468;hp=2d75e321334ae7b07f3894ae964b87a3992e6ef6;hpb=3661a670aa9e6224383bc1ab9612987887494df5;p=djsite.git diff --git a/quotes/tests.py b/quotes/tests.py index 2d75e32..36dcc1d 100644 --- a/quotes/tests.py +++ b/quotes/tests.py @@ -1,7 +1,7 @@ from django.test import TestCase, Client # Create your tests here. -from .models import Tag, Author, Work, Quote +from .models import QuoteTag, Author, Work, Quote import re import lxml.etree @@ -9,11 +9,11 @@ class QuoteTest(TestCase): def setUp(self): a1 = Author.objects.create(name="JFK") w1 = Work.objects.create(name="Berlin speech", author=a1) - q1 = Quote.objects.create(text="Ich bin...", work=w1) + q1 = Quote.objects.create(text="

Ich bin...

", work=w1) self.q1 = q1 def test_one(self): - q = Quote.objects.filter(text__startswith="Ich") + q = Quote.objects.filter(text__startswith="

Ich") self.assertEqual(q.count(), 1) q = q[0] self.assertEqual(q, self.q1) @@ -30,24 +30,25 @@ class ViewsTest(TestCase): lxml.etree.fromstring(document) except lxml.etree.XMLSyntaxError as e: self.assertTrue(False, 'Errors in page at %s: %s' % (url, e)) + self.assertFalse('") w1 = Work.objects.create(name="Context with some notes", author=a1, - notes="Some notes for the work") - q1 = Quote.objects.create(text="Quote01, two tags", + notes="

Some notes for the work

") + q1 = Quote.objects.create(text="

Quote01, two tags

", work=w1, - notes="Some notes for the quote") - t1 = Tag.objects.create(tag="tag01-1") - t2 = Tag.objects.create(tag="tag01-2") + notes="

Some notes for the quote

") + t1 = QuoteTag.objects.create(tag="tag01-1") + t2 = QuoteTag.objects.create(tag="tag01-2") q1.tags.add(t1, t2) a2 = Author.objects.create(name="Author without notes") w2 = Work.objects.create(name="Work without notes", author=a2) - q2 = Quote.objects.create(text="Quote02, no tags", work=w2) + q2 = Quote.objects.create(text="

Quote02, no tags

", work=w2) self.assertSequenceEqual(q2.tags.all(), []) def test_all(self): @@ -81,8 +82,8 @@ class ViewsTest(TestCase): self.assertTrue(seen[q.id]) def test_views_all_data(self): - q = Quote.objects.filter(text__startswith="Quote01") - self.assertEqual(q.count(), 1) + q = Quote.objects.filter(text__startswith="

Quote01") + self.assertEqual(q.count(), 1, "Couldn't find Quote01 after insertion") q = q[0] # check the individual quote page; each of the note type is displayed @@ -117,8 +118,9 @@ class ViewsTest(TestCase): self.assertIn(q.text, tagpage) def test_views_minimal_data(self): - q = Quote.objects.filter(text__startswith="Quote02") - self.assertEqual(q.count(), 1) + q = Quote.objects.filter(text__startswith="

Quote02") + self.assertEqual(q.count(), 1, + "Couldn't find Quote02 after insertion") q = q[0] quotepage = self.getPage('show/%s/' % q.id)