]> gitweb.fperrin.net Git - djsite.git/blob - quotes/test_search.py
Convert to using pytest
[djsite.git] / quotes / test_search.py
1 import pytest
2
3 from .models import Author, Work, Quote
4
5 class Test_Search():
6     @pytest.fixture(scope='function')
7     def q1(self, db):
8         a1 = Author.objects.create(name="JFK")
9         w1 = Work.objects.create(name="Berlin speech", author=a1)
10         q1 = Quote.objects.create(text="<p>Ich bin...</p>", work=w1)
11         return q1
12
13     @pytest.mark.django_db
14     def test_search(self, q1, c):
15         results = c.postPage('search/', {'q': 'Ich'})
16
17         assert 'JFK' in results
18
19     @pytest.mark.django_db
20     def test_emptysearch(self, q1, c):
21         assert c.postPage('search/', {'q': 'something that matches nothing'})