test_dossiers.py 1.86 KB
Newer Older
Nicolas Joyard's avatar
Nicolas Joyard committed
1
2
3
4
5
6
7
8
9
10
11
12
13
# -*- coding: utf8 -*-

from django.test import TestCase

from representatives_votes.models import Dossier

from .base import ResponseDiffMixin


class DossiersTest(ResponseDiffMixin, TestCase):
    fixtures = ['smaller_sample.json']

    def test_dossier_list(self):
14
15
16
        # session setup
        self.client.get('/votes/dossier/')

Nicolas Joyard's avatar
Nicolas Joyard committed
17
        # 1 query for chamber list (search form)
Nicolas Joyard's avatar
Nicolas Joyard committed
18
19
20
21
        # 1 query for dossier count
        # 1 query for dossiers
        # 1 query for proposals
        # 1 query for recommendations
Nicolas Joyard's avatar
Nicolas Joyard committed
22
23
24
        # 1 query for documents
        # 1 query for document chambers
        self.responsediff_test('/votes/dossier/', 7)
Nicolas Joyard's avatar
Nicolas Joyard committed
25

Nicolas Joyard's avatar
Nicolas Joyard committed
26
27
28
29
    def test_dossier_search(self):
        # session setup
        self.client.get('/votes/dossier/')

Nicolas Joyard's avatar
Nicolas Joyard committed
30
        # 1 query for chamber list (search form)
Nicolas Joyard's avatar
Nicolas Joyard committed
31
32
33
34
        # 1 query for dossier count
        # 1 query for dossiers
        # 1 query for proposals
        # 1 query for recommendations
Nicolas Joyard's avatar
Nicolas Joyard committed
35
36
        # 1 query for documents
        # 1 query for document chambers
Nicolas Joyard's avatar
Nicolas Joyard committed
37
        q = 'acta'
Nicolas Joyard's avatar
Nicolas Joyard committed
38
        self.responsediff_test('/votes/dossier/?search=%s' % q, 7)
Nicolas Joyard's avatar
Nicolas Joyard committed
39
40
41
42
43

    def test_dossier_search_noresults(self):
        # session setup
        self.client.get('/votes/dossier/')

Nicolas Joyard's avatar
Nicolas Joyard committed
44
        # 1 query for chamber list (search form)
Nicolas Joyard's avatar
Nicolas Joyard committed
45
46
47
        # 1 query for dossier count
        # nothing else since count = 0
        q = 'no-dossier-will-have-that-title-ever'
Nicolas Joyard's avatar
Nicolas Joyard committed
48
        self.responsediff_test('/votes/dossier/?search=%s' % q, 2)
Nicolas Joyard's avatar
Nicolas Joyard committed
49

Nicolas Joyard's avatar
Nicolas Joyard committed
50
51
52
53
    def test_dossier_detail(self):
        # Get 1st dossier in dataset
        dossier = Dossier.objects.order_by('pk')[0]

54
55
56
        # session setup
        self.client.get('/votes/dossier/%s/' % dossier.pk)

Nicolas Joyard's avatar
Nicolas Joyard committed
57
58
59
        # 1 query for the dossier
        # 1 query for proposals
        # 1 query for recommendations
Nicolas Joyard's avatar
Nicolas Joyard committed
60
61
62
        # 1 query for documents
        # 1 query for document chambers
        self.responsediff_test('/votes/dossier/%s/' % dossier.pk, 5)