toulouse_smart: slugify intervention's type name to make the id (#55250)

This commit is contained in:
Benjamin Dauvergne 2021-06-29 18:18:39 +02:00
parent c5378798ff
commit b3e450941b
2 changed files with 4 additions and 2 deletions

View File

@ -19,6 +19,7 @@ import datetime
import lxml.etree as ET
from django.contrib.postgres.fields import JSONField
from django.db import models
from django.utils.text import slugify
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
@ -88,8 +89,9 @@ class ToulouseSmartResource(BaseResource, HTTPResource):
return {
'data': [
{
'id': intervention_type['id'],
'id': slugify(intervention_type['name']),
'text': intervention_type['name'],
'uuid': intervention_type['id'],
}
for intervention_type in self.get_intervention_types()
]

View File

@ -126,7 +126,7 @@ URL = '/toulouse-smart/test/'
@mock_response(['/v1/type-intervention', INTERVENTION_TYPES])
def test_endpoint_intervention_types(app, smart):
resp = app.get(URL + 'type-intervention')
assert resp.json == {'data': [{'id': '1234', 'text': 'coin'}], 'err': 0}
assert resp.json == {'data': [{'id': 'coin', 'text': 'coin', 'uuid': '1234'}], 'err': 0}
@mock_response()