nanterre: ajoute date_de_modification dans le dico individu (#19834)
This commit is contained in:
parent
ec51940cf1
commit
3333e8e696
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue