1 from django.test import Client
3 # Create your tests here.
6 from .models import Author, Work, Quote
10 @pytest.fixture(scope='function')
12 a1 = Author.objects.create(name="JFK")
13 w1 = Work.objects.create(name="Berlin speech", author=a1)
14 q1 = Quote.objects.create(text="<p>Ich bin...</p>", work=w1)
17 def postPage(self, url, params, exp_status=200):
19 response = c.post('/quotes/' + url, params)
20 assert response.status_code == 200
21 assert response.charset == 'utf-8'
22 document = response.content.decode(response.charset)
23 lxml.etree.fromstring(document)
24 assert '<script>' not in document
28 @pytest.mark.django_db
29 def test_search(self, q1):
30 results = self.postPage('search/', {'q': 'Ich'})
32 assert 'JFK' in results