From d15ce1251fad47a682fe58a725ab3d913c52b864 Mon Sep 17 00:00:00 2001
From: Nicolas ROCHE <nroche@entrouvert.com>
Date: Mon, 19 Dec 2022 20:27:19 +0100
Subject: [PATCH 7/7] toulouse-maelis: update functests for subscritions
 (#72352)

---
 functests/toulouse_maelis/conftest.py         | 16 ++++++--
 .../data/test_create_child.json               |  2 +-
 .../data/test_create_family.json              | 37 +++++++++++++++++-
 .../data/test_update_family.json              | 39 +++++++++++++++++--
 .../data/test_update_family_ras.json          | 37 +++++++++++++++++-
 functests/toulouse_maelis/test_family.py      |  8 ++--
 6 files changed, 124 insertions(+), 15 deletions(-)

diff --git a/functests/toulouse_maelis/conftest.py b/functests/toulouse_maelis/conftest.py
index 6aa9f2c0..f7806e69 100644
--- a/functests/toulouse_maelis/conftest.py
+++ b/functests/toulouse_maelis/conftest.py
@@ -79,17 +79,17 @@ FAMILY_PAYLOAD = {
             },
         ],
     },
     'childList': [
         {
             'sexe': 'M',
             'firstname': 'Bart',
             'lastname': 'Simpson',
-            'birth': {'dateBirth': '1978-04-01'},
+            'birth': {'dateBirth': '2014-04-01'},
             'bPhoto': True,
             'bLeaveAlone': True,
             'dietcode': 'MENU_AV',
             'paiInfoBean': {
                 'code': 'PAI_01',
                 'dateDeb': '2022-09-01',
                 'dateFin': '2023-07-01',
                 'description': 'mischievous, rebellious, misunderstood, disruptive',
@@ -170,32 +170,42 @@ FAMILY_PAYLOAD = {
                     },
                 },
             ],
         },
         {
             'sexe': 'F',
             'firstname': 'Lisa',
             'lastname': 'Simpson',
-            'birth': {'dateBirth': '1980-05-09'},
+            'birth': {'dateBirth': '2016-05-09'},
             'dietcode': 'MENU_SV',
             'paiInfoBean': {
                 'code': 'PAI_02',
             },
         },
         {
             'sexe': 'F',
             'firstname': 'Maggie',
             'lastname': 'Simpson',
-            'birth': {'dateBirth': '1989-12-17'},
+            'birth': {'dateBirth': '2018-12-17'},
             'dietcode': 'MENU_PAI',
             'paiInfoBean': {
                 'code': 'PAI_02',
             },
         },
+        {
+            'sexe': 'M',
+            'firstname': 'Hugo',
+            'lastname': 'Simpson',
+            'birth': {'dateBirth': '2018-04-01'},
+            'dietcode': 'MENU_AV',
+            'paiInfoBean': {
+                'code': 'PAI_01',
+            },
+        },
     ],
     'emergencyPersonList': [
         {
             'civility': 'MME',
             'firstname': 'Patty',
             'lastname': 'Bouvier',
             'dateBirth': '1948-08-30',
             'sexe': 'F',
diff --git a/functests/toulouse_maelis/data/test_create_child.json b/functests/toulouse_maelis/data/test_create_child.json
index c36b9f74..454338ee 100644
--- a/functests/toulouse_maelis/data/test_create_child.json
+++ b/functests/toulouse_maelis/data/test_create_child.json
@@ -1,15 +1,15 @@
 {
   "num": "N/A",
   "lastname": "N/A",
   "firstname": "LISA",
   "sexe": "M",
   "birth": {
-    "dateBirth": "1980-05-09T00:00:00+02:00",
+    "dateBirth": "2016-05-09T00:00:00+02:00",
     "place": null,
     "communeCode": null,
     "countryCode": null
   },
   "dietcode": null,
   "bPhoto": false,
   "bLeaveAlone": false,
   "authorizedPersonList": [],
diff --git a/functests/toulouse_maelis/data/test_create_family.json b/functests/toulouse_maelis/data/test_create_family.json
index b6723d23..f7be3da3 100644
--- a/functests/toulouse_maelis/data/test_create_family.json
+++ b/functests/toulouse_maelis/data/test_create_family.json
@@ -49,17 +49,17 @@
   "quotientList": [],
   "childList": [
     {
       "num": "N/A",
       "lastname": "N/A",
       "firstname": "BART",
       "sexe": "M",
       "birth": {
-        "dateBirth": "1978-04-01T00:00:00+01:00",
+        "dateBirth": "2014-04-01T00:00:00+02:00",
         "place": null,
         "communeCode": null,
         "countryCode": null
       },
       "dietcode": "MENU_AV",
       "bPhoto": true,
       "bLeaveAlone": true,
       "authorizedPersonList": [
@@ -172,17 +172,17 @@
       "dietcode_text": "Avec viande"
     },
     {
       "num": "N/A",
       "lastname": "N/A",
       "firstname": "MAGGIE",
       "sexe": "F",
       "birth": {
-        "dateBirth": "1989-12-17T00:00:00+01:00",
+        "dateBirth": "2018-12-17T00:00:00+01:00",
         "place": null,
         "communeCode": null,
         "countryCode": null
       },
       "dietcode": "MENU_PAI",
       "bPhoto": false,
       "bLeaveAlone": false,
       "authorizedPersonList": [],
@@ -198,16 +198,49 @@
       },
       "mother": "N/A",
       "father": "N/A",
       "rl": null,
       "subscribeSchoolList": [],
       "subscribeActivityList": [],
       "sexe_text": "F\u00e9minin",
       "dietcode_text": "Panier"
+    },
+    {
+      "num": "N/A",
+      "lastname": "N/A",
+      "firstname": "HUGO",
+      "sexe": "M",
+      "birth": {
+        "dateBirth": "2018-04-01T00:00:00+02:00",
+        "place": null,
+        "communeCode": null,
+        "countryCode": null
+      },
+      "dietcode": "MENU_AV",
+      "bPhoto": false,
+      "bLeaveAlone": false,
+      "authorizedPersonList": [],
+      "indicatorList": [],
+      "medicalRecord": null,
+      "insurance": null,
+      "paiInfoBean": {
+        "code": "PAI_01",
+        "dateDeb": null,
+        "dateFin": null,
+        "description": null,
+        "code_text": "PAI M\u00e9dical"
+      },
+      "mother": "N/A",
+      "father": "N/A",
+      "rl": null,
+      "subscribeSchoolList": [],
+      "subscribeActivityList": [],
+      "sexe_text": "Masculin",
+      "dietcode_text": "Avec viande"
     }
   ],
   "emergencyPersonList": [
     {
       "numPerson": "N/A",
       "civility": "MME",
       "firstname": "PATTY",
       "lastname": "BOUVIER",
diff --git a/functests/toulouse_maelis/data/test_update_family.json b/functests/toulouse_maelis/data/test_update_family.json
index 10304f59..e1a17697 100644
--- a/functests/toulouse_maelis/data/test_update_family.json
+++ b/functests/toulouse_maelis/data/test_update_family.json
@@ -117,17 +117,17 @@
   "quotientList": [],
   "childList": [
     {
       "num": "N/A",
       "lastname": "N/A",
       "firstname": "BART",
       "sexe": "M",
       "birth": {
-        "dateBirth": "1978-04-01T00:00:00+01:00",
+        "dateBirth": "2014-04-01T00:00:00+02:00",
         "place": null,
         "communeCode": null,
         "countryCode": null
       },
       "dietcode": "MENU_AV",
       "bPhoto": true,
       "bLeaveAlone": true,
       "authorizedPersonList": [
@@ -240,17 +240,17 @@
       "dietcode_text": "Avec viande"
     },
     {
       "num": "N/A",
       "lastname": "N/A",
       "firstname": "LISA",
       "sexe": "F",
       "birth": {
-        "dateBirth": "1980-05-09T00:00:00+02:00",
+        "dateBirth": "2016-05-09T00:00:00+02:00",
         "place": null,
         "communeCode": null,
         "countryCode": null
       },
       "dietcode": "MENU_SV",
       "bPhoto": false,
       "bLeaveAlone": false,
       "authorizedPersonList": [],
@@ -273,17 +273,17 @@
       "dietcode_text": "Sans viande"
     },
     {
       "num": "N/A",
       "lastname": "N/A",
       "firstname": "MAGGIE",
       "sexe": "F",
       "birth": {
-        "dateBirth": "1989-12-17T00:00:00+01:00",
+        "dateBirth": "2018-12-17T00:00:00+01:00",
         "place": null,
         "communeCode": null,
         "countryCode": null
       },
       "dietcode": "MENU_PAI",
       "bPhoto": false,
       "bLeaveAlone": false,
       "authorizedPersonList": [],
@@ -299,16 +299,49 @@
       },
       "mother": "N/A",
       "father": "N/A",
       "rl": null,
       "subscribeSchoolList": [],
       "subscribeActivityList": [],
       "sexe_text": "F\u00e9minin",
       "dietcode_text": "Panier"
+    },
+    {
+      "num": "N/A",
+      "lastname": "N/A",
+      "firstname": "HUGO",
+      "sexe": "M",
+      "birth": {
+        "dateBirth": "2018-04-01T00:00:00+02:00",
+        "place": null,
+        "communeCode": null,
+        "countryCode": null
+      },
+      "dietcode": "MENU_AV",
+      "bPhoto": false,
+      "bLeaveAlone": false,
+      "authorizedPersonList": [],
+      "indicatorList": [],
+      "medicalRecord": null,
+      "insurance": null,
+      "paiInfoBean": {
+        "code": "PAI_01",
+        "dateDeb": null,
+        "dateFin": null,
+        "description": null,
+        "code_text": "PAI M\u00e9dical"
+      },
+      "mother": "N/A",
+      "father": "N/A",
+      "rl": null,
+      "subscribeSchoolList": [],
+      "subscribeActivityList": [],
+      "sexe_text": "Masculin",
+      "dietcode_text": "Avec viande"
     }
   ],
   "emergencyPersonList": [
     {
       "numPerson": "N/A",
       "civility": "MME",
       "firstname": "PATTY",
       "lastname": "BOUVIER",
diff --git a/functests/toulouse_maelis/data/test_update_family_ras.json b/functests/toulouse_maelis/data/test_update_family_ras.json
index f4836ed2..f6e9dd2e 100644
--- a/functests/toulouse_maelis/data/test_update_family_ras.json
+++ b/functests/toulouse_maelis/data/test_update_family_ras.json
@@ -173,17 +173,17 @@
       "sexe_text": "F\u00e9minin"
     },
     {
       "num": "N/A",
       "lastname": "N/A",
       "firstname": "LISA",
       "sexe": "F",
       "birth": {
-        "dateBirth": "1980-05-09T00:00:00+02:00",
+        "dateBirth": "2016-05-09T00:00:00+02:00",
         "place": null,
         "communeCode": null,
         "countryCode": null
       },
       "dietcode": "MENU_SV",
       "bPhoto": false,
       "bLeaveAlone": false,
       "authorizedPersonList": [],
@@ -206,17 +206,17 @@
       "dietcode_text": "Sans viande"
     },
     {
       "num": "N/A",
       "lastname": "N/A",
       "firstname": "MAGGIE",
       "sexe": "F",
       "birth": {
-        "dateBirth": "1989-12-17T00:00:00+01:00",
+        "dateBirth": "2018-12-17T00:00:00+01:00",
         "place": null,
         "communeCode": null,
         "countryCode": null
       },
       "dietcode": "MENU_PAI",
       "bPhoto": false,
       "bLeaveAlone": false,
       "authorizedPersonList": [],
@@ -232,16 +232,49 @@
       },
       "mother": "N/A",
       "father": "N/A",
       "rl": null,
       "subscribeSchoolList": [],
       "subscribeActivityList": [],
       "sexe_text": "F\u00e9minin",
       "dietcode_text": "Panier"
+    },
+    {
+      "num": "N/A",
+      "lastname": "N/A",
+      "firstname": "HUGO",
+      "sexe": "M",
+      "birth": {
+        "dateBirth": "2018-04-01T00:00:00+02:00",
+        "place": null,
+        "communeCode": null,
+        "countryCode": null
+      },
+      "dietcode": "MENU_AV",
+      "bPhoto": false,
+      "bLeaveAlone": false,
+      "authorizedPersonList": [],
+      "indicatorList": [],
+      "medicalRecord": null,
+      "insurance": null,
+      "paiInfoBean": {
+        "code": "PAI_01",
+        "dateDeb": null,
+        "dateFin": null,
+        "description": null,
+        "code_text": "PAI M\u00e9dical"
+      },
+      "mother": "N/A",
+      "father": "N/A",
+      "rl": null,
+      "subscribeSchoolList": [],
+      "subscribeActivityList": [],
+      "sexe_text": "Masculin",
+      "dietcode_text": "Avec viande"
     }
   ],
   "emergencyPersonList": [
     {
       "numPerson": "N/A",
       "civility": null,
       "firstname": "RESET",
       "lastname": "RESET",
diff --git a/functests/toulouse_maelis/test_family.py b/functests/toulouse_maelis/test_family.py
index bfefb5b2..dcbe745d 100644
--- a/functests/toulouse_maelis/test_family.py
+++ b/functests/toulouse_maelis/test_family.py
@@ -384,17 +384,17 @@ def test_update_coordinate(conn, update_data):
     assert diff_family(conn, update_data['name_id'], 'test_update_family.json')
 
 
 def test_is_child_exists(conn, create_data):
     url = conn + '/is-child-exists'
     payload = {
         'firstname': 'Maggie',
         'lastname': create_data['lastname'],
-        'dateBirth': '1989-12-17',
+        'dateBirth': create_data['family_payload']['childList'][1]['birth']['dateBirth'],
     }
     resp = requests.post(url, json=payload)
     resp.raise_for_status()
     assert resp.json() == {'err': 0, 'data': True}
 
     payload['firstname'] = payload['firstname'].upper()
     payload['lastname'] = payload['lastname'].lower()
     resp = requests.post(url, json=payload)
@@ -407,29 +407,29 @@ def test_is_child_exists(conn, create_data):
     assert resp.json() == {'err': 0, 'data': False}
 
 
 def test_create_child(conn, create_data, update_data):
     unlink(conn, create_data['name_id'])
     link(conn, create_data)
 
     data = read_family(conn, create_data['name_id'])
-    assert len(data['childList']) == 2
+    assert len(data['childList']) == 3
 
     url = conn + '/create-child?NameID=%s' % create_data['name_id']
     payload = {
         'sexe': 'M',
         'firstname': 'Lisa',
         'lastname': create_data['lastname'],
-        'birth': {'dateBirth': '1980-05-09'},
+        'birth': {'dateBirth': update_data['family_payload']['childList'][1]['birth']['dateBirth']},
     }
     resp = requests.post(url, json=payload)
     resp.raise_for_status()
     assert resp.json()['err'] == 0
-    assert diff_child(conn, create_data['name_id'], 2, 'test_create_child.json')
+    assert diff_child(conn, create_data['name_id'], 3, 'test_create_child.json')
 
     # child already exists error (Lisa form same family)
     resp = requests.post(url, json=payload)
     resp.raise_for_status()
     res = resp.json()
     assert 'Il existe déjà un enfant correspondant' in res['err_desc']
     res['err_desc'] = 'N/A'
     assert res == {
-- 
2.30.2

