Skip to content
GitLab
Explore
Sign in
Commits on Source (3)
version bumped to 0.3.0; changelog; data_import documentation now shows import from op api
· cbdc7e96
guglielmo
authored
Dec 08, 2017
cbdc7e96
import paths in codice_fiscale corrected
· b21abc2b
guglielmo
authored
Dec 10, 2017
b21abc2b
Bump version: 0.3.0 → 0.3.1
· 014ecac6
guglielmo
authored
Dec 11, 2017
014ecac6
Hide whitespace changes
Inline
Side-by-side
.bumpversion.cfg
View file @
014ecac6
[bumpversion]
current_version
= 0.3.
0
current_version
= 0.3.
1
commit
= True
[bumpversion:file:web/opdm_service/__init__.py]
...
...
CHANGELOG.md
View file @
014ecac6
...
...
@@ -5,7 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to
[
Semantic Versioning
](
http://semver.org/spec/v2.0.0.html
)
.
## [Unreleased]
### Added
-
import for persons from openpolis API started
## [0.2.0]
### Added
...
...
docs/data_import.rst
View file @
014ecac6
...
...
@@ -100,3 +100,22 @@ Data can be imported with the following code block:
.. code-block::
python manage.py import_orgs_from_bdap -v2
Persons, Posts and Memberships
------------------------------
Persons and their Memberships and Posts, are imported from the Openpolis API,
at: http://api3.openpolis.it/politici/
The command is:
.. code-block::
python manage.py import_posts_and_persons_from_op [c1 c2 c3] -v2
One or more contexts can be specified as command line arguments.
The accepted values are:
- eu - European Commission and Parliament
- it - Italian Government and Parliament (Camera and Senato)
- reg - Regional governments and councils
- prov - Provincial or Metropolitan areas governments and councils
- com - Municipalities governments and councils
web/opdm_service/__init__.py
View file @
014ecac6
"
The Openpolis Data Manager service package (the backend)
"
__version__
=
'
0.3.
0
'
__version__
=
'
0.3.
1
'
web/opdm_service/codice_fiscale/test.py
View file @
014ecac6
# -*- coding: utf-8 -*-
"""
Calcolo del codice fiscale italiano a partire dai dati anagrafici.
Calcolo del codice fiscale italiano a partire dai dati anagrafici.
Questo modulo contiene i test per codicefiscale.py.
"""
import
unittest
from
datetime
import
date
from
codicefiscale
import
(
codice_cognome
,
codice_nome
,
codice_nascita
,
from
.
codicefiscale
import
(
codice_cognome
,
codice_nome
,
codice_nascita
,
codice_geografia
,
codice_controllo
,
codice_fiscale
,
InvalidDataError
)
import
db
from
.
import
db
class
CognomeTest
(
unittest
.
TestCase
):
def
test_normale
(
self
):
self
.
assertEqual
(
codice_cognome
(
u
'
Rossi
'
),
'
RSS
'
)
def
test_corto
(
self
):
self
.
assertEqual
(
codice_cognome
(
u
'
Bo
'
),
'
BOX
'
)
def
test_corto_inversione
(
self
):
self
.
assertEqual
(
codice_cognome
(
u
'
Al
'
),
'
LAX
'
)
def
test_due_consonanti
(
self
):
self
.
assertEqual
(
codice_cognome
(
u
'
aresio
'
),
'
RSA
'
)
def
test_una_consonante
(
self
):
self
.
assertEqual
(
codice_cognome
(
u
'
aesio
'
),
'
SAE
'
)
def
test_doppio
(
self
):
self
.
assertEqual
(
codice_cognome
(
u
'
Di Nanni
'
),
'
DNN
'
)
def
test_apostrofo
(
self
):
self
.
assertEqual
(
codice_cognome
(
u
"
D
'
Andrea
"
),
'
DND
'
)
def
test_caratteri_accentati
(
self
):
self
.
assertEqual
(
codice_cognome
(
u
'
Noè
'
),
'
NOE
'
)
class
NomeTest
(
unittest
.
TestCase
):
def
test_normale
(
self
):
# la prima, terza e quarta consonante!
...
...
@@ -47,7 +47,7 @@ class NomeTest(unittest.TestCase):
class
NascitaTest
(
unittest
.
TestCase
):
def
test_gennaio_maschio
(
self
):
self
.
assertEqual
(
codice_nascita
(
date
(
1950
,
1
,
15
),
'
m
'
),
'
50A15
'
)
def
test_dicembre_femmina
(
self
):
self
.
assertEqual
(
codice_nascita
(
date
(
1950
,
12
,
5
),
'
f
'
),
'
50T45
'
)
...
...
@@ -56,40 +56,40 @@ class GeografiaTest(unittest.TestCase):
def
setUp
(
self
):
self
.
con
=
db
.
Connessione
()
self
.
db
=
self
.
con
.
codici_geografici
def
test_italia
(
self
):
self
.
assertEqual
(
codice_geografia
(
'
ITALIA
'
,
'
BA
'
,
'
MOLFETTA
'
,
self
.
db
),
'
F284
'
)
def
test_italia_inesistente
(
self
):
with
self
.
assertRaises
(
db
.
DBNoDataError
):
with
self
.
assertRaises
(
db
.
DBNoDataError
):
codice_geografia
(
'
ITALIA
'
,
'
BA
'
,
'
???
'
,
self
.
db
)
def
test_estero
(
self
):
self
.
assertEqual
(
codice_geografia
(
'
ALBANIA
'
,
'
?
'
,
'
?
'
,
self
.
db
),
'
Z100
'
)
def
test_estero_inesistente
(
self
):
with
self
.
assertRaises
(
db
.
DBNoDataError
):
with
self
.
assertRaises
(
db
.
DBNoDataError
):
codice_geografia
(
'
?
'
,
'
?
'
,
'
?
'
,
self
.
db
)
def
tearDown
(
self
):
self
.
con
.
chiudi
()
class
ControlloTest
(
unittest
.
TestCase
):
def
test_normale
(
self
):
# alcuni codici veri da testare...
for
cod
in
(
'
GRPLCR71R24L912N
'
,
'
MRARSS34P12A662Z
'
,
'
GNNBOX78S63I754Q
'
,
'
DLAHUX86C50F952H
'
,
'
RSMBLL12P65E472F
'
,
'
DDDRMO56B12E625V
'
):
cc
=
codice_controllo
(
cod
[:
-
1
])
self
.
assertEqual
(
cc
,
cod
[
-
1
],
self
.
assertEqual
(
cc
,
cod
[
-
1
],
'
errore in %s: atteso %s, trovato %s
'
%
(
cod
,
cod
[
-
1
],
cc
))
def
test_caratteri_non_ammessi
(
self
):
with
self
.
assertRaises
(
InvalidDataError
):
with
self
.
assertRaises
(
InvalidDataError
):
codice_controllo
(
'
;-)
'
)
class
FiscaleTest
(
unittest
.
TestCase
):
class
FiscaleTest
(
unittest
.
TestCase
):
pass
cognome_suite
=
unittest
.
TestLoader
().
loadTestsFromTestCase
(
CognomeTest
)
...
...
@@ -99,11 +99,10 @@ geografia_suite = unittest.TestLoader().loadTestsFromTestCase(GeografiaTest)
controllo_suite
=
unittest
.
TestLoader
().
loadTestsFromTestCase
(
ControlloTest
)
fiscale_suite
=
unittest
.
TestLoader
().
loadTestsFromTestCase
(
FiscaleTest
)
all_tests
=
unittest
.
TestSuite
([
cognome_suite
,
nome_suite
,
nascita_suite
,
all_tests
=
unittest
.
TestSuite
([
cognome_suite
,
nome_suite
,
nascita_suite
,
geografia_suite
,
controllo_suite
,
fiscale_suite
])
if
__name__
==
'
__main__
'
:
unittest
.
TextTestRunner
().
run
(
all_tests
)
raw_input
()
\ No newline at end of file