-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')
q1 = Quote.objects.create(text="<p>Ich bin...</p>", 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 '<script>' not in document
- print document
- return document
-
@pytest.mark.django_db
- def test_search(self, q1):
- results = self.postPage('search/', {'q': 'Ich'})
+ def test_search(self, q1, c):
+ results = c.postPage('search/', {'q': 'Ich'})
assert 'JFK' in results
+
+ @pytest.mark.django_db
+ def test_emptysearch(self, q1, c):
+ assert c.postPage('search/', {'q': 'something that matches nothing'})