From 7169c938475164a264c92bb1c888386ff8d3258e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Perrin?= Date: Thu, 3 Nov 2016 19:36:55 +0000 Subject: [PATCH] Add a search page --- quotes/test_search.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 quotes/test_search.py diff --git a/quotes/test_search.py b/quotes/test_search.py new file mode 100644 index 0000000..3a06d3e --- /dev/null +++ b/quotes/test_search.py @@ -0,0 +1,32 @@ +from django.test import Client + +# Create your tests here. +import pytest + +from .models import Author, Work, Quote +import lxml.etree + +class Test_Search(): + @pytest.fixture(scope='function') + def q1(self, db): + a1 = Author.objects.create(name="JFK") + w1 = Work.objects.create(name="Berlin speech", author=a1) + q1 = Quote.objects.create(text="

Ich bin...

", work=w1) + return q1 + + def postPage(self, url, params, exp_status=200): + c = Client() + response = c.post('/quotes/' + url, params) + assert response.status_code == 200 + assert response.charset == 'utf-8' + document = response.content.decode(response.charset) + lxml.etree.fromstring(document) + assert '