Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Political Memory
memopol
Commits
1a0fcce3
Commit
1a0fcce3
authored
Jun 08, 2016
by
Nicolas Joyard
Browse files
Add tests for dossier views
parent
d0616ab0
Changes
5
Show whitespace changes
Inline
Side-by-side
memopol/tests/base.py
View file @
1a0fcce3
...
...
@@ -3,6 +3,8 @@ import os.path
from
django.test
import
Client
from
responsediff.response
import
Response
class
UrlGetTestMixin
(
object
):
url
=
None
...
...
@@ -35,3 +37,16 @@ class UrlGetTestMixin(object):
with
open
(
expected
,
'r'
)
as
f
:
self
.
assertHtmlInResult
(
f
.
read
())
class
ResponseDiffMixin
(
object
):
def
responsediff_test
(
self
,
url
,
numQueries
):
# Setup session variables
self
.
client
.
get
(
url
)
with
self
.
assertNumQueries
(
numQueries
):
response
=
self
.
client
.
get
(
url
)
expected
=
Response
.
for_test
(
self
)
expected
.
assertNoDiff
(
response
)
memopol/tests/response_fixtures/DossiersTest.test_dossier_detail/content
0 → 100644
View file @
1a0fcce3
<!DOCTYPE html>
<html
class=
"no-js"
lang=
"en"
>
<!--<![endif]-->
<head>
<meta
charset=
"utf-8"
/>
<link
rel=
"icon"
type=
"image/png"
href=
"/static/collected/img/favicon.ico"
/>
<!-- Set the viewport width to device width for mobile -->
<meta
name=
"viewport"
content=
"width=device-width"
/>
<title>
Home
- The Political Memory of
</title>
<link
rel=
"stylesheet"
href=
"/static/collected/libs/bootstrap/dist/css/bootstrap.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/fontawesome/css/font-awesome.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/flag-icon-css/css/flag-icon.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/CACHE/css/base.3c5ffeab3cbf.css"
type=
"text/css"
/>
<script
type=
"text/javascript"
src=
"/static/collected/libs/jquery/dist/jquery.js"
></script>
<script
type=
"text/javascript"
src=
"/static/collected/libs/bootstrap/dist/js/bootstrap.js"
></script>
</head>
<body
>
<!-- -load memopol_tags cache -->
<div
id=
'header'
class=
'container-fluid'
>
<a
id=
'logo'
href=
'/'
>
<img
src=
'/static/collected/images/logo.png'
/>
</a>
<h1>
<a
id=
'header_banner'
href=
'/'
>
Political Memory
</a>
</h1>
<p
class=
'organization'
>
</p>
</div>
<div
id=
'nav'
class=
'container-fluid'
>
<ul
class=
'nav'
>
<li>
<a
href=
'/legislature/representative/'
>
Representatives
</a>
</li>
<li>
<a
href=
'/legislature/group/country/'
>
Countries
</a>
</li>
<li>
<a
href=
'/legislature/group/chamber/'
>
Chambers
</a>
</li>
<li>
<a
href=
'/legislature/group/group/'
>
Parties
</a>
</li>
<li>
<a
href=
'/legislature/group/delegation/'
>
Delegations
</a>
</li>
<li>
<a
href=
'/legislature/group/committee/'
>
Committees
</a>
</li>
<li>
<a
href=
'/votes/dossier/'
>
Dossiers
</a>
</li>
</ul>
</div>
<div
class=
"container-fluid main-container"
>
<h1>
Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)
</h1>
<p>
<strong>
2010/2935(RSP)
</strong>
</p>
<h2>
Recommendations
</h2>
<table
class=
'table'
>
<tr>
<th>
Proposal
</th>
<th>
Title
</th>
<th>
Recommendation
</th>
<th>
Status
</th>
<th><i
aria-label=
"for"
class=
"fa fa-thumbs-up vote_positive"
title=
"for"
></i></th>
<th><i
aria-label=
"against"
class=
"fa fa-thumbs-down vote_negative"
title=
"against"
></i></th>
<th><i
aria-label=
"abstain"
class=
"fa fa-circle-o vote_abstain"
title=
"abstain"
></i></th>
</tr>
<tr>
<td>
RC-B7-0617/2010 - Accord commercial anti-contrefaçon (ACAC) - Considérant X
<br
/>
<small>
B7-0617/2010
Considérant X
</small>
</td>
<td>
Stop acta !
</td>
<td><i
aria-label=
"for"
class=
"fa fa-thumbs-up vote_positive"
title=
"for"
></i></td>
<td>
adopted
</td>
<td>
329
</td>
<td>
249
</td>
<td>
75
</td>
</tr>
<tr>
<td>
RC-B7-0617/2010 - Accord commercial anti-contrefaçon (ACAC) - Considérant CC
<br
/>
<small>
B7-0617/2010
Considérant CC
</small>
</td>
<td>
Stop acta !
</td>
<td><i
aria-label=
"for"
class=
"fa fa-thumbs-up vote_positive"
title=
"for"
></i></td>
<td>
adopted
</td>
<td>
315
</td>
<td>
312
</td>
<td>
14
</td>
</tr>
<tr>
<td>
RC-B7-0617/2010 - Accord commercial anti-contrefaçon (ACAC) - Résolution
<br
/>
<small>
B7-0617/2010
Résolution
</small>
</td>
<td>
Stop acta !
</td>
<td><i
aria-label=
"for"
class=
"fa fa-thumbs-up vote_positive"
title=
"for"
></i></td>
<td>
rejected
</td>
<td>
306
</td>
<td>
322
</td>
<td>
26
</td>
</tr>
</table>
</div>
<div
id=
'footer'
class=
'container-fluid'
>
Memopol is free software
<a
href=
"https://github.com/political-memory/political_memory"
>
released
</a>
under the terms of the
<a
href=
"http://www.gnu.org/licenses/agpl.html"
>
GNU aGPLV3+
</a>
<a
href=
'https://github.com/political-memory/political_memory/issues'
>
Bug tracking system
</a>
<a
href=
'https://github.com/political-memory/political_memory/issues/new'
>
Report a bug
</a>
<br
/>
Provided by
<a
href=
"http://www.laquadrature.net/"
>
La Quadrature du Net
</a>
</div>
</body>
</html>
memopol/tests/response_fixtures/DossiersTest.test_dossier_list/content
0 → 100644
View file @
1a0fcce3
<!DOCTYPE html>
<html
class=
"no-js"
lang=
"en"
>
<!--<![endif]-->
<head>
<meta
charset=
"utf-8"
/>
<link
rel=
"icon"
type=
"image/png"
href=
"/static/collected/img/favicon.ico"
/>
<!-- Set the viewport width to device width for mobile -->
<meta
name=
"viewport"
content=
"width=device-width"
/>
<title>
Home
- The Political Memory of
</title>
<link
rel=
"stylesheet"
href=
"/static/collected/libs/bootstrap/dist/css/bootstrap.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/fontawesome/css/font-awesome.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/libs/flag-icon-css/css/flag-icon.min.css"
type=
"text/css"
/><link
rel=
"stylesheet"
href=
"/static/collected/CACHE/css/base.3c5ffeab3cbf.css"
type=
"text/css"
/>
<script
type=
"text/javascript"
src=
"/static/collected/libs/jquery/dist/jquery.js"
></script>
<script
type=
"text/javascript"
src=
"/static/collected/libs/bootstrap/dist/js/bootstrap.js"
></script>
</head>
<body
>
<!-- -load memopol_tags cache -->
<div
id=
'header'
class=
'container-fluid'
>
<a
id=
'logo'
href=
'/'
>
<img
src=
'/static/collected/images/logo.png'
/>
</a>
<h1>
<a
id=
'header_banner'
href=
'/'
>
Political Memory
</a>
</h1>
<p
class=
'organization'
>
</p>
</div>
<div
id=
'nav'
class=
'container-fluid'
>
<ul
class=
'nav'
>
<li>
<a
href=
'/legislature/representative/'
>
Representatives
</a>
</li>
<li>
<a
href=
'/legislature/group/country/'
>
Countries
</a>
</li>
<li>
<a
href=
'/legislature/group/chamber/'
>
Chambers
</a>
</li>
<li>
<a
href=
'/legislature/group/group/'
>
Parties
</a>
</li>
<li>
<a
href=
'/legislature/group/delegation/'
>
Delegations
</a>
</li>
<li>
<a
href=
'/legislature/group/committee/'
>
Committees
</a>
</li>
<li>
<a
href=
'/votes/dossier/'
>
Dossiers
</a>
</li>
</ul>
</div>
<div
class=
"container-fluid main-container"
>
<h1>
Dossiers
</h1>
<table
class=
'table'
>
<tr>
<th>
Title
</th>
<th>
Recommendations
</th>
<th>
Reference
</th>
</tr>
<tr>
<td>
<a
href=
'/votes/dossier/28147/'
>
Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)
</a>
</td>
<td>
3
</td>
<td>
2010/2935(RSP)
</td>
</tr>
</table>
<div
class=
'pagination-block'
>
<nav>
<ul
class=
'pagination pagination-sm'
>
</ul>
</nav>
<div
class=
'count'
>
Number of results : 1
<br
/>
Number of displayed results :
12
(
<a
href=
'?paginate_by=12'
>
12
</a>
/
<a
href=
'?paginate_by=24'
>
24
</a>
/
<a
href=
'?paginate_by=48'
>
48
</a>
/
<a
href=
'?paginate_by=96'
>
96
</a>
)
</div>
</div>
</div>
<div
id=
'footer'
class=
'container-fluid'
>
Memopol is free software
<a
href=
"https://github.com/political-memory/political_memory"
>
released
</a>
under the terms of the
<a
href=
"http://www.gnu.org/licenses/agpl.html"
>
GNU aGPLV3+
</a>
<a
href=
'https://github.com/political-memory/political_memory/issues'
>
Bug tracking system
</a>
<a
href=
'https://github.com/political-memory/political_memory/issues/new'
>
Report a bug
</a>
<br
/>
Provided by
<a
href=
"http://www.laquadrature.net/"
>
La Quadrature du Net
</a>
</div>
</body>
</html>
memopol/tests/test_dossiers.py
0 → 100644
View file @
1a0fcce3
# -*- 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
):
# 1 query for dossier count
# 1 query for dossiers
# 1 query for proposals
# 1 query for recommendations
self
.
responsediff_test
(
'/votes/dossier/'
,
4
)
def
test_dossier_detail
(
self
):
# Get 1st dossier in dataset
dossier
=
Dossier
.
objects
.
order_by
(
'pk'
)[
0
]
# 1 query for the dossier
# 1 query for proposals
# 1 query for recommendations
self
.
responsediff_test
(
'/votes/dossier/%s/'
%
dossier
.
pk
,
3
)
memopol/tests/test_group_list.py
View file @
1a0fcce3
...
...
@@ -2,23 +2,14 @@
from
django.test
import
TestCase
from
responsediff.respon
se
import
Response
from
.ba
se
import
Response
DiffMixin
class
GroupListTest
(
TestCase
):
class
GroupListTest
(
ResponseDiffMixin
,
TestCase
):
fixtures
=
[
'smaller_sample.json'
]
def
group_test
(
self
,
kind
,
numQueries
):
url
=
'/legislature/group/%s/'
%
kind
# Setup session variables
self
.
client
.
get
(
url
)
with
self
.
assertNumQueries
(
numQueries
):
response
=
self
.
client
.
get
(
url
)
expected
=
Response
.
for_test
(
self
)
expected
.
assertNoDiff
(
response
)
self
.
responsediff_test
(
'/legislature/group/%s/'
%
kind
,
numQueries
)
def
test_chambers
(
self
):
# 1 query for chambers
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment