0001-api_entreprise-don-t-try-to-parse-dates-for-string-l.patch
passerelle/apps/api_entreprise/models.py | ||
---|---|---|
24 | 24 | |
25 | 25 |
from django.db import models |
26 | 26 |
from django.utils.translation import ugettext_lazy as _ |
27 |
from django.utils import six |
|
27 | 28 |
from django.utils.timezone import datetime, make_aware, timedelta |
28 | 29 |
from django.http import HttpResponse, Http404 |
29 | 30 |
from django.core import signing |
... | ... | |
44 | 45 |
normalize_dates(data[key]) |
45 | 46 |
if isinstance(data[key], list): |
46 | 47 |
for item in data[key]: |
48 |
# list items could be strings |
|
49 |
if isinstance(item, six.string_types): |
|
50 |
continue |
|
47 | 51 |
normalize_dates(item) |
48 | 52 | |
49 | 53 |
if key.startswith('date') and not key.endswith('timestamp'): |
tests/test_api_entreprise.py | ||
---|---|---|
193 | 193 |
"type_voie": "RUE", |
194 | 194 |
"libelle_voie": "Lebouis", |
195 | 195 |
"code_insee": "75120", |
196 |
"code_postal": "75014",
|
|
196 |
"code_postal": ["75014", "75014"],
|
|
197 | 197 |
"commune": "Paris" |
198 | 198 |
}, |
199 | 199 |
"groupement": "Simple", |
... | ... | |
361 | 361 |
assert data['association']['date_publication'] == '1993-03-03' |
362 | 362 | |
363 | 363 |
assert 'adresse_siege' in data['association'] |
364 |
assert data['association']['adresse_siege']['code_postal'] == '75014'
|
|
364 |
assert data['association']['adresse_siege']['code_postal'] == ['75014', '75014']
|
|
365 | 365 |
assert data['association']['adresse_siege']['code_insee'] == '75120' |
366 | 366 | |
367 | 367 | |
368 |
- |