]> gitweb.fperrin.net Git - djsite.git/blobdiff - quotes/test_search.py
Convert to using pytest
[djsite.git] / quotes / test_search.py
index 3a06d3e67b795c5874122abcf67fca393142917f..49b59daec8ec4ea82e927268a94d71a2cfd9c585 100644 (file)
@@ -1,10 +1,6 @@
-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')
@@ -14,19 +10,12 @@ class Test_Search():
         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'})