Commit 9c884e2a authored by James Pic's avatar James Pic
Browse files

Merge pull request #47 from political-memory/pr

Release
parents de0af789 832e7e33
<div class='positions'>
<h2>Public positions</h2>
<table class='table table-condensed'>
<tr class='position'>
<td>24/11/2010</td>
<td>
<a href='/positions/position/2/'>
first-validated
</a>
</td>
<td>
<span class='label label-default'>
acta
</span>
<span class='label label-default'>
bar
</span>
</td>
<td>
<a href='http://example.com/first-validated'>
http://example.com/first-validated
</a>
</td>
</tr>
<tr class='position'>
<td>24/11/2010</td>
<td>
<a href='/positions/position/3/'>
other-validated
</a>
</td>
<td>
<span class='label label-default'>
acta
</span>
</td>
<td>
<a href='http://example.com/second-validated'>
http://example.com/second-validated
</a>
</td>
</tr>
<th>Score</th>
<td>
<span class="label label-danger">-7</span>
</td>
<h2 id='votes'>Votes</h2>
<table class='table table-condensed votes'>
<tr>
<th>Title</th>
<th class='icon-cell'>
Memopol recommendation
</th>
<th class='icon-cell'>
Representative vote
</th>
<th class='icon-cell'>
Score
</th>
</tr>
<tr>
<td>Stop acta !</td>
<td class='icon-cell'>
<i aria-label="for" class="fa fa-thumbs-up vote_positive" title="for" ></i>
</td>
<td class='icon-cell'>
<i aria-label="for" class="fa fa-thumbs-up vote_positive" title="for" ></i>
</td>
<td class='icon-cell'>
<span class="label label-success">4</span>
</td>
</tr>
<tr>
<td>Stop acta !</td>
<td class='icon-cell'>
<i aria-label="for" class="fa fa-thumbs-up vote_positive" title="for" ></i>
</td>
<td class='icon-cell'>
<i aria-label="against" class="fa fa-thumbs-down vote_negative" title="against" ></i>
</td>
<td class='icon-cell'>
<span class="label label-danger">-5</span>
</td>
</tr>
<tr>
<td>Stop acta !</td>
<td class='icon-cell'>
<i aria-label="for" class="fa fa-thumbs-up vote_positive" title="for" ></i>
</td>
<td class='icon-cell'>
<i aria-label="against" class="fa fa-thumbs-down vote_negative" title="against" ></i>
</td>
<td class='icon-cell'>
<span class="label label-danger">-6</span>
</td>
</tr>
</table>
import re
import os.path
from django.test import Client
class UrlGetTestMixin(object):
url = None
def setUp(self):
self.client = Client()
if not hasattr(type(self), 'response'):
# Do it once and for all, note that this also caches content types
# so the contenttype query used by taggit won't be counted in
# test_num_queries.
self.__class__.response = self.client.get(self.url)
self.response = self.__class__.response
def assertHtmlInResult(self, expected):
compare = re.sub('[\s"\']', '', expected)
result = re.sub('[\s"\']', '', self.response.content)
self.assertIn(compare, result)
def assertExpectedHtmlInResult(self):
"""
For test_votes_display, it is:
/positions/tests/test_representatives_detail_test_votes_display_expected.html
"""
expected = os.path.join(
os.path.dirname(__file__),
type(self).__name__,
'%s.html' % self._testMethodName
)
with open(expected, 'r') as f:
self.assertHtmlInResult(f.read())
This diff is collapsed.
# -*- coding: utf8 -*-
from django.test import TestCase
from .base import UrlGetTestMixin
class RepresentativeListTest(UrlGetTestMixin, TestCase):
fixtures = ['smaller_sample.json']
url = '/legislature/representative/'
def functional_test(self, page, paginate_by, display, search=''):
url = '%s?page=%s&search=%s' % (self.url, page, search)
# Cancel out one-time queries (session)
self.client.get('%s&paginate_by=%s&display=%s' %
(url, paginate_by, display))
with self.assertNumQueries(3):
"""
- A count for pagination
- One query for representative + score
- One query for mandates (including country + main_mandate)
"""
self.response = self.client.get(url)
self.assertExpectedHtmlInResult()
def test_page1_paginateby12_displaylist(self):
self.functional_test(1, 12, 'list')
def test_page1_paginateby24_displaygrid(self):
self.functional_test(1, 24, 'grid')
def test_page2_paginateby24_displaylist(self):
self.functional_test(2, 24, 'list')
def test_page1_paginateby12_displaylist_searchjoly(self):
self.functional_test(1, 12, 'list', 'joly')
def test_page2_paginateby12_displaylist(self):
self.functional_test(2, 12, 'list')
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment