From 20cf017d1670d76b70ecf4221d597bc07d08cffb Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 11 Mar 2019 16:18:33 +0100 Subject: [PATCH] mdph13: only validate valued date fields --- passerelle/contrib/mdph13/models.py | 4 ++-- tests/test_mdph13.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/passerelle/contrib/mdph13/models.py b/passerelle/contrib/mdph13/models.py index b0061d8..7132777 100644 --- a/passerelle/contrib/mdph13/models.py +++ b/passerelle/contrib/mdph13/models.py @@ -157,8 +157,8 @@ class MDPH13Resource(BaseResource, HTTPResource): def check(value, path): if path[-1].startswith('date_'): - if (not isinstance(value, six.text_type) - or not self.DATE_RE.match(value)): + if (isinstance(value, six.text_type) + and not self.DATE_RE.match(value)): errors.append('%s is not a date string' % '.'.join(path)) json_walker(data, check) if errors: diff --git a/tests/test_mdph13.py b/tests/test_mdph13.py index c559ad2..3420c8c 100644 --- a/tests/test_mdph13.py +++ b/tests/test_mdph13.py @@ -93,7 +93,7 @@ VALID_RESPONSE = json.dumps({ "prestation": "Carte d'invalidité (de priorité) pour personne handicapée", "statut": "Instruction administrative terminée en attente de passage en évaluation", "typologie": "Demande En Cours", - "date_decision": "2015-01-16" + "date_decision": None, }, { "numero": "1210524", -- 2.20.1