atal: switch comment variables names (#37904)

This commit is contained in:
Emmanuel Cazenave 2019-11-25 10:00:50 +01:00
parent 8c3815f6cd
commit 6be3533a71
2 changed files with 16 additions and 16 deletions

View File

@ -223,7 +223,7 @@ class ATALConnector(BaseResource):
raise APIError('Could not get a status')
responses = (demand_details.get('reponses') or {}).get('Reponse') or []
demand_comments = []
works_comments = []
if responses:
for response in responses:
comment = {
@ -232,24 +232,24 @@ class ATALConnector(BaseResource):
}
if 'dateReponse' in response:
comment['date'] = dateformat.format(response['dateReponse'], DATE_FORMAT)
demand_comments.append(comment)
works_comments.append(comment)
demand_comment = {
works_comment = {
'text': None,
'date': None
}
if demand_comments:
demand_comment = demand_comments[-1]
if works_comments:
works_comment = works_comments[-1]
data = {
'status': status,
'demand_comment': demand_comment,
'works_comment': works_comment,
'demand_details': None,
'demand_comments': []
'works_comments': []
}
if full:
data['demand_details'] = demand_details
data['demand_comments'] = demand_comments
data['works_comments'] = works_comments
if status not in ('PRISE EN COMPTE', 'ARCHIVEE'):
return {
@ -267,7 +267,7 @@ class ATALConnector(BaseResource):
raise APIError('Could not get a status')
data['status'] = status
data['works_comment'] = works_status.get('commentaires', '')
data['demand_comment'] = works_status.get('commentaires', '')
data['works_status'] = None
if full:

View File

@ -298,12 +298,12 @@ def test_infos(app, connector, monkeypatch):
assert response.json['err'] == 0
data = response.json['data']
assert data['status'] == u'travaux pas commencés'
assert data['demand_comment'] == {
assert data['works_comment'] == {
'text': 'bonjour atal',
'date': 'Thursday 24 October 2019, 16:51'
}
assert data['demand_comments'] == []
assert data['works_comment'] is None
assert data['works_comments'] == []
assert data['demand_comment'] is None
assert data['works_status'] is None
# full in query string
@ -312,8 +312,8 @@ def test_infos(app, connector, monkeypatch):
)
response = app.get('/atal/slug-atal/infos/DIT18050001/?full=true')
data = response.json['data']
assert len(data['demand_comments']) == 2
assert data['demand_comments'][0] == {
assert len(data['works_comments']) == 2
assert data['works_comments'][0] == {
'text': 'OK',
'date': 'Thursday 24 October 2019, 16:48'
}
@ -321,5 +321,5 @@ def test_infos(app, connector, monkeypatch):
'text': 'bonjour atal',
'date': 'Thursday 24 October 2019, 16:51'
}
assert data['demand_comments'][1] == last_comment
assert data['demand_comment'] == last_comment
assert data['works_comments'][1] == last_comment
assert data['works_comment'] == last_comment