Merge branch 'master' into nanterre-recette
This commit is contained in:
commit
5f8ff17d4a
|
@ -57,6 +57,7 @@ def test_person_search_api(app, db, rsu):
|
|||
for individu in response.json['data']:
|
||||
assert individu['statut_legal'] == statut
|
||||
assert (now() - isodate.parse_datetime(individu['date_de_creation'])).seconds < 100
|
||||
assert individu['date_de_modification'] == individu['date_de_creation']
|
||||
|
||||
|
||||
def test_create_individu(transactional_db, app, rsu_schema):
|
||||
|
@ -121,6 +122,19 @@ def test_create_individu(transactional_db, app, rsu_schema):
|
|||
assert Relation.objects.count() == 1
|
||||
assert Log.objects.filter(entity__id=first_id).count() == 1
|
||||
|
||||
# extraction depuis l'API
|
||||
get_url = reverse('rsu-api-reseau', kwargs={'identifier': first_id})
|
||||
response = app.get(get_url)
|
||||
assert response.json['err'] == 0
|
||||
individu = response.json['data']
|
||||
assert individu['prenoms'] == 'JEAN EUDE'
|
||||
assert individu['nom_de_naissance'] == 'MICHALON-GOURDE'
|
||||
assert individu['nom_d_usage'] == u'GRÉGOIRE'
|
||||
assert individu['date_de_naissance'] == '1992-03-04'
|
||||
assert individu['adresses'][0]['streetname'] == 'ALLE DE L\'ARLEQUIN'
|
||||
assert (now() - isodate.parse_datetime(individu['date_de_creation'])).seconds < 100
|
||||
assert individu['date_de_modification'] == individu['date_de_creation']
|
||||
|
||||
# mise à jour premier adulte
|
||||
update_url = reverse('rsu-api-reseau', kwargs={
|
||||
'identifier': first_id})
|
||||
|
@ -150,6 +164,20 @@ def test_create_individu(transactional_db, app, rsu_schema):
|
|||
streetname = get_individu_adresse(entity).content['streetname']
|
||||
assert streetname == u'ALLÉE DE L\'ARLEQUIN'
|
||||
|
||||
# extraction via l'API
|
||||
get_url = reverse('rsu-api-reseau', kwargs={'identifier': first_id})
|
||||
response = app.get(get_url)
|
||||
assert response.json['err'] == 0
|
||||
individu = response.json['data']
|
||||
assert individu['prenoms'] == 'JEAN EUDE'
|
||||
assert individu['nom_de_naissance'] == 'MICHALON-GOURDE'
|
||||
assert individu['nom_d_usage'] == u'GRÉGORIO'
|
||||
assert individu['date_de_naissance'] == '1991-03-04'
|
||||
assert individu['adresses'][0]['streetname'] == u'ALLÉE DE L\'ARLEQUIN'
|
||||
assert (now() - isodate.parse_datetime(individu['date_de_modification'])).seconds < 100
|
||||
assert individu['date_de_modification'] != individu['date_de_creation']
|
||||
|
||||
# vérification dans la base
|
||||
assert Entity.objects.count() == 2
|
||||
assert Entity.objects.filter(schema__slug='individu').count() == 1
|
||||
assert Entity.objects.filter(schema__slug='adresse').count() == 1
|
||||
|
|
|
@ -25,6 +25,7 @@ def test_list_doublons(nanterre_classic_family, app):
|
|||
second_id = max(e['jean'].id, e['marie'].id)
|
||||
assert response.json['data'][0]['individu_1']['id'] == first_id
|
||||
assert response.json['data'][0]['individu_2']['id'] == second_id
|
||||
assert response.json['data'][0]['score'] == 100
|
||||
|
||||
new = []
|
||||
for i in range(100):
|
||||
|
@ -34,7 +35,7 @@ def test_list_doublons(nanterre_classic_family, app):
|
|||
Duplicate.objects.create(
|
||||
first=new[-1],
|
||||
second=e['marie'],
|
||||
score=1.0)
|
||||
score=(100-i/2)/100.0)
|
||||
|
||||
response = app.get(url)
|
||||
assert response.json['err'] == 0
|
||||
|
@ -47,6 +48,7 @@ def test_list_doublons(nanterre_classic_family, app):
|
|||
assert response.json['data'][0]['id'] == d.id
|
||||
assert response.json['data'][0]['individu_1']['id'] == first_id
|
||||
assert response.json['data'][0]['individu_2']['id'] == second_id
|
||||
assert response.json['data'][0]['score'] == 100
|
||||
first_data = response.json['data'][0]
|
||||
second_data = response.json['data'][1]
|
||||
|
||||
|
|
|
@ -107,6 +107,10 @@ def individu_to_response(individu, add_text=False, add_conjoint=True, add_enfant
|
|||
if add_text:
|
||||
d['text'] = individu_to_text(individu)
|
||||
d['date_de_creation'] = individu.created.created.isoformat()
|
||||
if individu.modified:
|
||||
d['date_de_modification'] = individu.modified.created.isoformat()
|
||||
else:
|
||||
d['date_de_modification'] = d['date_de_creation']
|
||||
return d
|
||||
|
||||
|
||||
|
@ -1800,6 +1804,7 @@ class DoublonMixin(object):
|
|||
'created': duplicate.created.isoformat(),
|
||||
'state': duplicate.get_state_display(),
|
||||
'state_id': duplicate.state,
|
||||
'score': int(duplicate.score * 100),
|
||||
'individu_1': individu_to_response(duplicate.first, add_text=True),
|
||||
'individu_2': individu_to_response(duplicate.second, add_text=True),
|
||||
'content': duplicate.content,
|
||||
|
|
Loading…
Reference in New Issue