diff --git a/.travis.yml b/.travis.yml index f4e45ee0d66d8b975400ac0fd5c8372b8f5b73a2..f377f49604ae1f6f5be838686eb84db4844b83e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,9 @@ python: before_install: - pip install codecov install: -- pip install $DJANGO pep8 flake8 pytest-django pytest-cov codecov +- pip install $DJANGO pep8 flake8 pytest-django pytest-cov codecov django-responsediff - pip install https://github.com/political-memory/django-representatives/archive/parltrack.tar.gz#egg=django-representatives -- pip install -e . +- pip install -e .[api] script: - django-admin migrate - flake8 representatives_votes/ --exclude migrations --ignore E128 diff --git a/representatives_votes/fixtures/representatives_votes_test.json b/representatives_votes/fixtures/representatives_votes_test.json new file mode 100644 index 0000000000000000000000000000000000000000..d2afc5ca9946766d7d5e1e5464f72f264972d31d --- /dev/null +++ b/representatives_votes/fixtures/representatives_votes_test.json @@ -0,0 +1,835 @@ +[ +{ + "fields": { + "updated": "2015-12-27T11:51:14.770Z", + "reference": "2012/2002(INI)", + "title": "Agenda for change: the future of EU development policy", + "text": "", + "created": "2015-12-27T11:51:14.770Z", + "link": "http://www.europarl.europa.eu/oeil/popups/ficheprocedure.do?reference=2012/2002(INI)", + "fingerprint": "9e2cccdc5f6d22afd008af8b5b55dc193c27c5d6" + }, + "model": "representatives_votes.dossier", + "pk": 1 +}, +{ + "fields": { + "updated": "2015-12-27T11:51:14.781Z", + "reference": "2015/2132(BUD)", + "title": "2016 general budget: all sections", + "text": "", + "created": "2015-12-27T11:51:14.781Z", + "link": "http://www.europarl.europa.eu/oeil/popups/ficheprocedure.do?reference=2015/2132(BUD)", + "fingerprint": "e6856e0880e701c1022f23d595cc37a9a1cdcca8" + }, + "model": "representatives_votes.dossier", + "pk": 2 +}, +{ + "fields": { + "updated": "2015-12-27T11:51:24.327Z", + "total_for": 0, + "description": "", + "reference": "A7-0234/2012", + "title": "A7-0234/2012 - Charles Goerens - \u00a7 31", + "dossier": 1, + "created": "2015-12-27T11:51:24.327Z", + "kind": "\u00a7 31", + "datetime": "2012-10-23T16:31:10Z", + "total_against": 0, + "fingerprint": "6c1fb67feac3ab2ea567b37aa7dfd0d578bc04b4", + "total_abstain": 2 + }, + "model": "representatives_votes.proposal", + "pk": 1 +}, +{ + "fields": { + "updated": "2015-12-27T11:51:24.340Z", + "total_for": 2, + "description": "", + "reference": "A7-0234/2012", + "title": "A7-0234/2012 - Charles Goerens - R\u00e9solution", + "dossier": 1, + "created": "2015-12-27T11:51:24.340Z", + "kind": "R\u00e9solution", + "datetime": "2012-10-23T16:34:32Z", + "total_against": 0, + "fingerprint": "18df8a97581832a95f3bdfb8c14ba2b05abb91e9", + "total_abstain": 0 + }, + "model": "representatives_votes.proposal", + "pk": 2 +}, +{ + "fields": { + "updated": "2015-12-27T11:51:24.353Z", + "total_for": 0, + "description": "", + "reference": "A8-0298/2015", + "title": "A8-0298/2015 - Jos\u00e9 Manuel Fernandes et G\u00e9rard Deprez - Am 4", + "dossier": 2, + "created": "2015-12-27T11:51:24.353Z", + "kind": "Am 4", + "datetime": "2015-10-28T11:59:35Z", + "total_against": 2, + "fingerprint": "4e575a1bc17602d23d2f0acf8ee482ebe08de79c", + "total_abstain": 0 + }, + "model": "representatives_votes.proposal", + "pk": 3 +}, +{ + "fields": { + "updated": "2015-12-27T11:51:24.367Z", + "total_for": 1, + "description": "", + "reference": "A8-0298/2015", + "title": "A8-0298/2015 - Jos\u00e9 Manuel Fernandes et G\u00e9rard Deprez - Am 29", + "dossier": 2, + "created": "2015-12-27T11:51:24.367Z", + "kind": "Am 29", + "datetime": "2015-10-28T12:00:12Z", + "total_against": 1, + "fingerprint": "fc786534e832d9af7e2cdcd0b0952d7d60bb4331", + "total_abstain": 0 + }, + "model": "representatives_votes.proposal", + "pk": 4 +}, +{ + "fields": { + "updated": "2015-12-27T11:51:24.386Z", + "total_for": 0, + "description": "", + "reference": "A8-0298/2015", + "title": "A8-0298/2015 - Jos\u00e9 Manuel Fernandes et G\u00e9rard Deprez - Am 31", + "dossier": 2, + "created": "2015-12-27T11:51:24.386Z", + "kind": "Am 31", + "datetime": "2015-10-28T12:00:42Z", + "total_against": 1, + "fingerprint": "90c022cf70dc6ceff796b876d3e1b814620c8637", + "total_abstain": 1 + }, + "model": "representatives_votes.proposal", + "pk": 5 +}, +{ + "fields": { + "updated": "2015-12-27T11:51:24.411Z", + "total_for": 2, + "description": "", + "reference": "A8-0298/2015", + "title": "A8-0298/2015 - Jos\u00e9 Manuel Fernandes et G\u00e9rard Deprez - Am 30", + "dossier": 2, + "created": "2015-12-27T11:51:24.411Z", + "kind": "Am 30", + "datetime": "2015-10-28T12:01:09Z", + "total_against": 0, + "fingerprint": "5b3aa46182803c11d70ccfec666234b9fe2f44a7", + "total_abstain": 0 + }, + "model": "representatives_votes.proposal", + "pk": 6 +}, +{ + "fields": { + "representative_name": "", + "position": "abstain", + "proposal": 1, + "representative": 2 + }, + "model": "representatives_votes.vote", + "pk": 1 +}, +{ + "fields": { + "representative_name": "", + "position": "abstain", + "proposal": 1, + "representative": 1 + }, + "model": "representatives_votes.vote", + "pk": 2 +}, +{ + "fields": { + "representative_name": "", + "position": "for", + "proposal": 2, + "representative": 2 + }, + "model": "representatives_votes.vote", + "pk": 3 +}, +{ + "fields": { + "representative_name": "", + "position": "for", + "proposal": 2, + "representative": 1 + }, + "model": "representatives_votes.vote", + "pk": 4 +}, +{ + "fields": { + "representative_name": "", + "position": "against", + "proposal": 3, + "representative": 2 + }, + "model": "representatives_votes.vote", + "pk": 5 +}, +{ + "fields": { + "representative_name": "", + "position": "against", + "proposal": 3, + "representative": 1 + }, + "model": "representatives_votes.vote", + "pk": 6 +}, +{ + "fields": { + "representative_name": "", + "position": "for", + "proposal": 4, + "representative": 1 + }, + "model": "representatives_votes.vote", + "pk": 7 +}, +{ + "fields": { + "representative_name": "", + "position": "against", + "proposal": 4, + "representative": 2 + }, + "model": "representatives_votes.vote", + "pk": 8 +}, +{ + "fields": { + "representative_name": "", + "position": "abstain", + "proposal": 5, + "representative": 1 + }, + "model": "representatives_votes.vote", + "pk": 9 +}, +{ + "fields": { + "representative_name": "", + "position": "against", + "proposal": 5, + "representative": 2 + }, + "model": "representatives_votes.vote", + "pk": 10 +}, +{ + "fields": { + "representative_name": "", + "position": "for", + "proposal": 6, + "representative": 1 + }, + "model": "representatives_votes.vote", + "pk": 11 +}, +{ + "fields": { + "code": "AT", + "name": "Austria" + }, + "model": "representatives.country", + "pk": 1043 +}, +{ + "fields": { + "code": "SE", + "name": "Sweden" + }, + "model": "representatives.country", + "pk": 1202 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:23.995Z", + "last_name": "PIRKER", + "photo": "http://www.europarl.europa.eu/mepphoto/2307.jpg", + "created": "2015-12-13T02:07:23.995Z", + "gender": 2, + "remote_id": "2307", + "first_name": "Hubert", + "cv": "Transport and security spokesman, \u00d6VP Delegation, European Parliament;\nsecurity spokesman, \u00d6VP Delegation, European Parliament (2006-2009); security spokesman (coordinator), EPP Group (1999-2004); Deputy Head of \u00d6VP Delegation, European Parliament (1996-2004);", + "active": false, + "birth_place": "Gries", + "full_name": "Hubert PIRKER", + "fingerprint": "2a3c90346d40e9c540050534d832ceb3e0d25a49", + "birth_date": "1948-10-03", + "slug": "hubert-pirker" + }, + "model": "representatives.representative", + "pk": 1 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.361Z", + "last_name": "LUDVIGSSON", + "photo": "http://www.europarl.europa.eu/mepphoto/96673.jpg", + "created": "2015-12-13T02:07:24.361Z", + "gender": 2, + "remote_id": "96673", + "first_name": "Olle", + "cv": "", + "active": true, + "birth_place": "H\u00e4ls\u00f6", + "full_name": "Olle LUDVIGSSON", + "fingerprint": "314d0f4c25af31bfa2a6b286838367994b902615", + "birth_date": "1948-10-28", + "slug": "olle-ludvigsson" + }, + "model": "representatives.representative", + "pk": 2 +}, +{ + "fields": { + "email": "olle.ludvigsson@europarl.europa.eu", + "updated": "2015-12-13T02:07:24.404Z", + "representative": 2, + "kind": "official", + "created": "2015-12-13T02:07:24.404Z" + }, + "model": "representatives.email", + "pk": 1 +}, +{ + "fields": { + "url": "http://www.sap.se/olle", + "updated": "2015-12-13T02:07:24.406Z", + "representative": 2, + "kind": "", + "created": "2015-12-13T02:07:24.406Z" + }, + "model": "representatives.website", + "pk": 1 +}, +{ + "fields": { + "url": "http://twitter.com/olleludvigsson", + "updated": "2015-12-13T02:07:24.407Z", + "representative": 2, + "kind": "twitter", + "created": "2015-12-13T02:07:24.407Z" + }, + "model": "representatives.website", + "pk": 2 +}, +{ + "fields": { + "url": "https://www.facebook.com/olle.ludvigsson", + "updated": "2015-12-13T02:07:24.408Z", + "representative": 2, + "kind": "facebook", + "created": "2015-12-13T02:07:24.408Z" + }, + "model": "representatives.website", + "pk": 3 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:23.997Z", + "name": "Committee on Employment and Social Affairs", + "created": "2015-12-13T02:07:23.996Z", + "kind": "committee", + "abbreviation": "EMPL", + "fingerprint": "7f0e6d2c3342dde2c6077e127a418a19e0e891bb" + }, + "model": "representatives.group", + "pk": 1 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.002Z", + "name": "Delegation for relations with the countries of Southeast Asia and the Association of Southeast Asian Nations (ASEAN)", + "created": "2015-12-13T02:07:24.002Z", + "kind": "delegation", + "abbreviation": "", + "fingerprint": "23bb5f3e808b2ea6a02ddbe01705714ecfe7a82a" + }, + "model": "representatives.group", + "pk": 2 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.006Z", + "name": "Delegation for relations with the Member States of ASEAN, South-east Asia and the Republic of Korea", + "created": "2015-12-13T02:07:24.005Z", + "kind": "delegation", + "abbreviation": "", + "fingerprint": "3d0bc2c9506b90bb22e02e3866c1d14c9be1867e" + }, + "model": "representatives.group", + "pk": 3 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.009Z", + "name": "Group of the European People's Party (Christian Democrats) and European Democrats", + "created": "2015-12-13T02:07:24.009Z", + "kind": "group", + "abbreviation": "PPE-DE", + "fingerprint": "cab4a9a406aa114716967e6fd6e698dfd2421794" + }, + "model": "representatives.group", + "pk": 4 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.013Z", + "name": "Group of the European People's Party (Christian-Democratic Group)", + "created": "2015-12-13T02:07:24.013Z", + "kind": "group", + "abbreviation": "EPP", + "fingerprint": "669373eca233e4101a0af25debda58fdfd59741f" + }, + "model": "representatives.group", + "pk": 5 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.017Z", + "name": "Austria", + "created": "2015-12-13T02:07:24.017Z", + "kind": "country", + "abbreviation": "AT", + "fingerprint": "7b37fb29f750421d82ee36539c2cb5bca9cef938" + }, + "model": "representatives.group", + "pk": 6 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.024Z", + "name": "Conference of Delegation Chairs", + "created": "2015-12-13T02:07:24.024Z", + "kind": "organization", + "abbreviation": "", + "fingerprint": "eb99949bb40fd2e906d738eef276a912c5412f67" + }, + "model": "representatives.group", + "pk": 7 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.362Z", + "name": "Committee on Economic and Monetary Affairs", + "created": "2015-12-13T02:07:24.362Z", + "kind": "committee", + "abbreviation": "ECON", + "fingerprint": "2da973401cd76bb56b36f3a9162cda13d2f2d8f3" + }, + "model": "representatives.group", + "pk": 8 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.366Z", + "name": "Committee on Industry, Research and Energy", + "created": "2015-12-13T02:07:24.366Z", + "kind": "committee", + "abbreviation": "ITRE", + "fingerprint": "17ff1a9fe036e400612c9153c1647a8258c34d63" + }, + "model": "representatives.group", + "pk": 9 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.372Z", + "name": "Delegation to the EU-Serbia Stabilisation and Association Parliamentary Committee", + "created": "2015-12-13T02:07:24.372Z", + "kind": "delegation", + "abbreviation": "", + "fingerprint": "a24b4e184cf25f0e300c07a1402b65243f5ba93d" + }, + "model": "representatives.group", + "pk": 10 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.375Z", + "name": "Delegation for relations with Bosnia and Herzegovina, and Kosovo", + "created": "2015-12-13T02:07:24.375Z", + "kind": "delegation", + "abbreviation": "", + "fingerprint": "3d2d9370cc501b1208a4692baf69deeab1e65d0a" + }, + "model": "representatives.group", + "pk": 11 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.379Z", + "name": "Delegation for relations with Australia and New Zealand", + "created": "2015-12-13T02:07:24.379Z", + "kind": "delegation", + "abbreviation": "", + "fingerprint": "1e5d79317501c2fdf7f36846ad1d5491a244a103" + }, + "model": "representatives.group", + "pk": 12 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.383Z", + "name": "Group of the Progressive Alliance of Socialists and Democrats in the European Parliament", + "created": "2015-12-13T02:07:24.383Z", + "kind": "group", + "abbreviation": "SD", + "fingerprint": "729890eba3ce20f90808b32110871d1fe41b53b6" + }, + "model": "representatives.group", + "pk": 13 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.389Z", + "name": "Sweden", + "created": "2015-12-13T02:07:24.389Z", + "kind": "country", + "abbreviation": "SE", + "fingerprint": "ea4cacc64af470d01e5b4da150b8b9d3a9dc4bfe" + }, + "model": "representatives.group", + "pk": 14 +}, +{ + "fields": { + "country": null, + "updated": "2015-12-13T02:07:23.998Z", + "fingerprint": "bc0c3668435accfa5da4479c80478fe68d15ddb1", + "name": "European Parliament", + "created": "2015-12-13T02:07:23.998Z" + }, + "model": "representatives.constituency", + "pk": 1 +}, +{ + "fields": { + "country": 1043, + "updated": "2015-12-13T02:07:24.018Z", + "fingerprint": "74e9c77e0664716d098cb1194927b86f2aa55f7e", + "name": "\u00d6sterreichische Volkspartei", + "created": "2015-12-13T02:07:24.018Z" + }, + "model": "representatives.constituency", + "pk": 2 +}, +{ + "fields": { + "country": 1202, + "updated": "2015-12-13T02:07:24.390Z", + "fingerprint": "a8fa2ff595aedee63954c3b5ad6e1dcd5dfac910", + "name": "Arbetarepartiet- Socialdemokraterna", + "created": "2015-12-13T02:07:24.390Z" + }, + "model": "representatives.constituency", + "pk": 3 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.001Z", + "group": 1, + "end_date": "1999-07-19", + "created": "2015-12-13T02:07:24.001Z", + "role": "Substitute", + "representative": 1, + "fingerprint": "9d2cdb45658e7b535e4b39de233b8e2f747bc1d1", + "link": "", + "begin_date": "1997-01-16", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 1 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.005Z", + "group": 2, + "end_date": "2014-06-30", + "created": "2015-12-13T02:07:24.005Z", + "role": "Member", + "representative": 1, + "fingerprint": "18613b505dc43a9a3055bf7aed2b2651246838f8", + "link": "", + "begin_date": "2013-10-09", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 2 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.008Z", + "group": 3, + "end_date": "1997-01-15", + "created": "2015-12-13T02:07:24.008Z", + "role": "Member", + "representative": 1, + "fingerprint": "fd6db1f22987be42ba290e1f8fbfda6cc109dd7e", + "link": "", + "begin_date": "1996-11-14", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 3 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.011Z", + "group": 4, + "end_date": "2004-07-19", + "created": "2015-12-13T02:07:24.011Z", + "role": "Member", + "representative": 1, + "fingerprint": "1d054cac567dd5bc523ddf2063dd05971d7b9c88", + "link": "", + "begin_date": "1999-07-20", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 4 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.015Z", + "group": 5, + "end_date": "1999-07-19", + "created": "2015-12-13T02:07:24.015Z", + "role": "Member", + "representative": 1, + "fingerprint": "0cfeaa28bfa4036f385bd7d81f29be83120fc985", + "link": "", + "begin_date": "1996-11-11", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 5 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.020Z", + "group": 6, + "end_date": "2004-07-19", + "created": "2015-12-13T02:07:24.020Z", + "role": "", + "representative": 1, + "fingerprint": "d761586241fb47f9fae7035365f5253cd8a363fb", + "link": "", + "begin_date": "1999-07-20", + "constituency": 2 + }, + "model": "representatives.mandate", + "pk": 6 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.023Z", + "group": 6, + "end_date": "1999-07-19", + "created": "2015-12-13T02:07:24.023Z", + "role": "", + "representative": 1, + "fingerprint": "5e7d170fc24b161457a09baebcc388edcbddc954", + "link": "", + "begin_date": "1996-11-11", + "constituency": 2 + }, + "model": "representatives.mandate", + "pk": 7 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.026Z", + "group": 7, + "end_date": "2009-07-13", + "created": "2015-12-13T02:07:24.026Z", + "role": "Member", + "representative": 1, + "fingerprint": "0926a8c1dbc827362c3eabfdca87a5b595706120", + "link": "", + "begin_date": "2006-03-21", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 8 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.364Z", + "group": 8, + "end_date": "9999-12-31", + "created": "2015-12-13T02:07:24.364Z", + "role": "Member", + "representative": 2, + "fingerprint": "5323fd311cf0cb24122be532666fabb7ef23fa0c", + "link": "", + "begin_date": "2014-07-01", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 9 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.368Z", + "group": 9, + "end_date": "9999-12-31", + "created": "2015-12-13T02:07:24.368Z", + "role": "Substitute", + "representative": 2, + "fingerprint": "9d57bd7941ddda428728446908f8dd7aa642c764", + "link": "", + "begin_date": "2014-07-08", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 10 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.371Z", + "group": 8, + "end_date": "2012-01-18", + "created": "2015-12-13T02:07:24.371Z", + "role": "Substitute", + "representative": 2, + "fingerprint": "5953eb229dd3c0993c1af3654fa7dfc052614002", + "link": "", + "begin_date": "2009-07-16", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 11 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.374Z", + "group": 10, + "end_date": "9999-12-31", + "created": "2015-12-13T02:07:24.374Z", + "role": "Member", + "representative": 2, + "fingerprint": "20a93b100a172b29f9ec6c6f94a8faeb1754a075", + "link": "", + "begin_date": "2014-07-14", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 12 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.378Z", + "group": 11, + "end_date": "9999-12-31", + "created": "2015-12-13T02:07:24.378Z", + "role": "Substitute", + "representative": 2, + "fingerprint": "b65a685d8e4144e36aff12b64bf6d835af1b95a5", + "link": "", + "begin_date": "2015-05-18", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 13 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.382Z", + "group": 12, + "end_date": "2013-01-10", + "created": "2015-12-13T02:07:24.382Z", + "role": "Substitute", + "representative": 2, + "fingerprint": "681dac891286446feb02863db19826f079cfed12", + "link": "", + "begin_date": "2009-09-17", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 14 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.385Z", + "group": 13, + "end_date": "9999-12-31", + "created": "2015-12-13T02:07:24.385Z", + "role": "Member", + "representative": 2, + "fingerprint": "f5c73825add38bb2c5f8de70d88b9effa6d6527f", + "link": "", + "begin_date": "2014-07-01", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 15 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.388Z", + "group": 13, + "end_date": "2014-06-30", + "created": "2015-12-13T02:07:24.388Z", + "role": "Member", + "representative": 2, + "fingerprint": "5765a17282ede4b110bedd2af0b1e5cc87673e6e", + "link": "", + "begin_date": "2009-07-14", + "constituency": 1 + }, + "model": "representatives.mandate", + "pk": 16 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.392Z", + "group": 14, + "end_date": "9999-12-31", + "created": "2015-12-13T02:07:24.392Z", + "role": "", + "representative": 2, + "fingerprint": "6058eddb2a4542a23de70a2528993eba09b5817a", + "link": "", + "begin_date": "2014-07-01", + "constituency": 3 + }, + "model": "representatives.mandate", + "pk": 17 +}, +{ + "fields": { + "updated": "2015-12-13T02:07:24.395Z", + "group": 14, + "end_date": "2014-06-30", + "created": "2015-12-13T02:07:24.395Z", + "role": "", + "representative": 2, + "fingerprint": "4d9c58327c6b94bdf8a01e5c4d1fbcf751abaf8f", + "link": "", + "begin_date": "2009-07-14", + "constituency": 3 + }, + "model": "representatives.mandate", + "pk": 18 +} +] diff --git a/representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_dossiers/content b/representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_dossiers/content new file mode 100644 index 0000000000000000000000000000000000000000..6debdc0202a1c801637d412d720e865d952a706f --- /dev/null +++ b/representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_dossiers/content @@ -0,0 +1 @@ +[{"id":1,"fingerprint":"9e2cccdc5f6d22afd008af8b5b55dc193c27c5d6","title":"Agenda for change: the future of EU development policy","reference":"2012/2002(INI)","text":"","link":"http://www.europarl.europa.eu/oeil/popups/ficheprocedure.do?reference=2012/2002(INI)","url":"http://testserver/api/dossiers/1/?format=json"},{"id":2,"fingerprint":"e6856e0880e701c1022f23d595cc37a9a1cdcca8","title":"2016 general budget: all sections","reference":"2015/2132(BUD)","text":"","link":"http://www.europarl.europa.eu/oeil/popups/ficheprocedure.do?reference=2015/2132(BUD)","url":"http://testserver/api/dossiers/2/?format=json"}] \ No newline at end of file diff --git a/representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_proposals/content b/representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_proposals/content new file mode 100644 index 0000000000000000000000000000000000000000..c0a75c439180fe1e39e57031278e297126eac492 --- /dev/null +++ b/representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_proposals/content @@ -0,0 +1 @@ +[{"id":1,"fingerprint":"6c1fb67feac3ab2ea567b37aa7dfd0d578bc04b4","dossier":"9e2cccdc5f6d22afd008af8b5b55dc193c27c5d6","dossier_title":"Agenda for change: the future of EU development policy","dossier_reference":"2012/2002(INI)","title":"A7-0234/2012 - Charles Goerens - § 31","description":"","reference":"A7-0234/2012","datetime":"2012-10-23T16:31:10Z","kind":"§ 31","total_abstain":2,"total_against":0,"total_for":0,"url":"http://testserver/api/proposals/1/?format=json"},{"id":2,"fingerprint":"18df8a97581832a95f3bdfb8c14ba2b05abb91e9","dossier":"9e2cccdc5f6d22afd008af8b5b55dc193c27c5d6","dossier_title":"Agenda for change: the future of EU development policy","dossier_reference":"2012/2002(INI)","title":"A7-0234/2012 - Charles Goerens - Résolution","description":"","reference":"A7-0234/2012","datetime":"2012-10-23T16:34:32Z","kind":"Résolution","total_abstain":0,"total_against":0,"total_for":2,"url":"http://testserver/api/proposals/2/?format=json"},{"id":3,"fingerprint":"4e575a1bc17602d23d2f0acf8ee482ebe08de79c","dossier":"e6856e0880e701c1022f23d595cc37a9a1cdcca8","dossier_title":"2016 general budget: all sections","dossier_reference":"2015/2132(BUD)","title":"A8-0298/2015 - José Manuel Fernandes et Gérard Deprez - Am 4","description":"","reference":"A8-0298/2015","datetime":"2015-10-28T11:59:35Z","kind":"Am 4","total_abstain":0,"total_against":2,"total_for":0,"url":"http://testserver/api/proposals/3/?format=json"},{"id":4,"fingerprint":"fc786534e832d9af7e2cdcd0b0952d7d60bb4331","dossier":"e6856e0880e701c1022f23d595cc37a9a1cdcca8","dossier_title":"2016 general budget: all sections","dossier_reference":"2015/2132(BUD)","title":"A8-0298/2015 - José Manuel Fernandes et Gérard Deprez - Am 29","description":"","reference":"A8-0298/2015","datetime":"2015-10-28T12:00:12Z","kind":"Am 29","total_abstain":0,"total_against":1,"total_for":1,"url":"http://testserver/api/proposals/4/?format=json"},{"id":5,"fingerprint":"90c022cf70dc6ceff796b876d3e1b814620c8637","dossier":"e6856e0880e701c1022f23d595cc37a9a1cdcca8","dossier_title":"2016 general budget: all sections","dossier_reference":"2015/2132(BUD)","title":"A8-0298/2015 - José Manuel Fernandes et Gérard Deprez - Am 31","description":"","reference":"A8-0298/2015","datetime":"2015-10-28T12:00:42Z","kind":"Am 31","total_abstain":1,"total_against":1,"total_for":0,"url":"http://testserver/api/proposals/5/?format=json"},{"id":6,"fingerprint":"5b3aa46182803c11d70ccfec666234b9fe2f44a7","dossier":"e6856e0880e701c1022f23d595cc37a9a1cdcca8","dossier_title":"2016 general budget: all sections","dossier_reference":"2015/2132(BUD)","title":"A8-0298/2015 - José Manuel Fernandes et Gérard Deprez - Am 30","description":"","reference":"A8-0298/2015","datetime":"2015-10-28T12:01:09Z","kind":"Am 30","total_abstain":0,"total_against":0,"total_for":2,"url":"http://testserver/api/proposals/6/?format=json"}] \ No newline at end of file diff --git a/representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_votes/content b/representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_votes/content new file mode 100644 index 0000000000000000000000000000000000000000..91db1258d40efc9f047710cd6f54eb7c6c2b4417 --- /dev/null +++ b/representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_votes/content @@ -0,0 +1 @@ +[{"id":1,"proposal":"6c1fb67feac3ab2ea567b37aa7dfd0d578bc04b4","representative":"314d0f4c25af31bfa2a6b286838367994b902615","representative_name":"","position":"abstain"},{"id":2,"proposal":"6c1fb67feac3ab2ea567b37aa7dfd0d578bc04b4","representative":"2a3c90346d40e9c540050534d832ceb3e0d25a49","representative_name":"","position":"abstain"},{"id":3,"proposal":"18df8a97581832a95f3bdfb8c14ba2b05abb91e9","representative":"314d0f4c25af31bfa2a6b286838367994b902615","representative_name":"","position":"for"},{"id":4,"proposal":"18df8a97581832a95f3bdfb8c14ba2b05abb91e9","representative":"2a3c90346d40e9c540050534d832ceb3e0d25a49","representative_name":"","position":"for"},{"id":5,"proposal":"4e575a1bc17602d23d2f0acf8ee482ebe08de79c","representative":"314d0f4c25af31bfa2a6b286838367994b902615","representative_name":"","position":"against"},{"id":6,"proposal":"4e575a1bc17602d23d2f0acf8ee482ebe08de79c","representative":"2a3c90346d40e9c540050534d832ceb3e0d25a49","representative_name":"","position":"against"},{"id":7,"proposal":"fc786534e832d9af7e2cdcd0b0952d7d60bb4331","representative":"2a3c90346d40e9c540050534d832ceb3e0d25a49","representative_name":"","position":"for"},{"id":8,"proposal":"fc786534e832d9af7e2cdcd0b0952d7d60bb4331","representative":"314d0f4c25af31bfa2a6b286838367994b902615","representative_name":"","position":"against"},{"id":9,"proposal":"90c022cf70dc6ceff796b876d3e1b814620c8637","representative":"2a3c90346d40e9c540050534d832ceb3e0d25a49","representative_name":"","position":"abstain"},{"id":10,"proposal":"90c022cf70dc6ceff796b876d3e1b814620c8637","representative":"314d0f4c25af31bfa2a6b286838367994b902615","representative_name":"","position":"against"},{"id":11,"proposal":"5b3aa46182803c11d70ccfec666234b9fe2f44a7","representative":"2a3c90346d40e9c540050534d832ceb3e0d25a49","representative_name":"","position":"for"}] \ No newline at end of file diff --git a/representatives_votes/tests/settings.py b/representatives_votes/tests/settings.py index 8623f2e7e725a4f1e5c3e2e1e4e6fa4022d8f426..7bdbf35fcdc58e402e6fab3d6294ea61295fe73e 100644 --- a/representatives_votes/tests/settings.py +++ b/representatives_votes/tests/settings.py @@ -12,6 +12,8 @@ DATABASES = { } INSTALLED_APPS = ( + 'django.contrib.staticfiles', + 'rest_framework', 'representatives', 'representatives_votes', ) @@ -21,6 +23,7 @@ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' ROOT_URLCONF = 'representatives_votes.tests.urls' +STATIC_URL = '/static/' USE_I18N = True USE_L10N = True USE_TZ = True diff --git a/representatives_votes/tests/test_views.py b/representatives_votes/tests/test_views.py new file mode 100644 index 0000000000000000000000000000000000000000..ee6de9c164d51f44d52bf6b2566ddadceeb447bc --- /dev/null +++ b/representatives_votes/tests/test_views.py @@ -0,0 +1,21 @@ +from django import test + +from responsediff.response import Response + + +class RepresentativeManagerTest(test.TestCase): + fixtures = ['representatives_votes_test.json'] + + def functional_test(self, queries, url): + with self.assertNumQueries(queries): + result = test.client.Client().get(url) + Response.for_test(self).assertNoDiff(result) + + def test_dossiers(self): + self.functional_test(1, '/api/dossiers/?format=json') + + def test_proposals(self): + self.functional_test(1, '/api/proposals/?format=json') + + def test_votes(self): + self.functional_test(1, '/api/votes/?format=json') diff --git a/representatives_votes/tests/urls.py b/representatives_votes/tests/urls.py index 637600f58aa4445293fcc008d547253d34470ffe..19f82800c727b34592d5ea5031e0c524ee5c7b3c 100644 --- a/representatives_votes/tests/urls.py +++ b/representatives_votes/tests/urls.py @@ -1 +1,18 @@ -urlpatterns = [] +from django.conf.urls import include, url + +from rest_framework import routers + +from representatives_votes.api import ( + DossierViewSet, + ProposalViewSet, + VoteViewSet, +) + +router = routers.DefaultRouter() +router.register(r'dossiers', DossierViewSet) +router.register(r'proposals', ProposalViewSet) +router.register(r'votes', VoteViewSet) + +urlpatterns = [ + url(r'api/', include(router.urls)), +] diff --git a/setup.py b/setup.py index 9a3eefbdefbf7be84d4d01220cbe561ea3f43a4e..f73ad0747467a068ff730a5806384d6f371f9b3b 100644 --- a/setup.py +++ b/setup.py @@ -12,11 +12,17 @@ setup( license='GPLv3', keywords='django government parliament votes', install_requires=[ - 'django-representatives>=0.0.7', + 'django-representatives>=0.0.13', 'py-dateutil', 'pytz', 'ijson', ], + extras_require={ + 'api': [ + 'django-filter', + 'djangorestframework', + ] + }, entry_points={ 'console_scripts': [ 'parltrack_import_dossiers = representatives_votes.contrib.parltrack.import_dossiers:main',