Development #67326 » update_family_test.py
1 |
#!/usr/bin/python3
|
---|---|
2 |
|
3 |
import logging.config |
4 |
import requests |
5 |
import sys |
6 |
import zeep |
7 |
from zeep.transports import Transport |
8 |
from zeep.wsse.username import UsernameToken |
9 |
|
10 |
logging.config.dictConfig({ |
11 |
'version': 1, |
12 |
'formatters': { |
13 |
'verbose': { |
14 |
'format': '%(name)s: %(message)s' |
15 |
}
|
16 |
},
|
17 |
'handlers': { |
18 |
'console': { |
19 |
'level': 'DEBUG', |
20 |
'class': 'logging.StreamHandler', |
21 |
'formatter': 'verbose', |
22 |
},
|
23 |
},
|
24 |
'loggers': { |
25 |
'zeep.transports': { |
26 |
'level': 'DEBUG', |
27 |
'propagate': True, |
28 |
'handlers': ['console'], |
29 |
},
|
30 |
}
|
31 |
})
|
32 |
|
33 |
|
34 |
WSSE = UsernameToken('maelis-webservice', 'maelis-password') |
35 |
WSDL_URL = 'https://demo-toulouse.sigec.fr/maelisws-toulouse/services/FamilyService?wsdl' |
36 |
|
37 |
|
38 |
session = requests.Session() |
39 |
session.verify = False |
40 |
transport = Transport(session=session) |
41 |
client = zeep.Client(WSDL_URL, transport=transport, wsse=WSSE) |
42 |
|
43 |
RL = client.get_type('ns0:rlInfoBean') |
44 |
Address = client.get_type('ns3:addressBean') |
45 |
BirthInfo = client.get_type('ns1:birthInfoBean') |
46 |
Child = client.get_type('ns1:childInfoBean') # !! |
47 |
|
48 |
address = Address( |
49 |
#idStreet='',
|
50 |
#num='',
|
51 |
#numComp='',
|
52 |
street1='Chateau', |
53 |
#street2='',
|
54 |
town='Paris', |
55 |
zipcode='75014', |
56 |
)
|
57 |
rl1 = RL( |
58 |
#num='123', # pour avoir une erreur soap aussi
|
59 |
lastname='Doee', |
60 |
firstname='Jhon', |
61 |
quality='AU', |
62 |
dateBirth='1938-07-26', |
63 |
adresse=address, |
64 |
)
|
65 |
rl2 = RL( |
66 |
lastname='Doe', |
67 |
firstname='Jannette', |
68 |
quality='MERE', |
69 |
dateBirth='1940-06-22', |
70 |
adresse=address, |
71 |
)
|
72 |
birth_info = BirthInfo( |
73 |
dateBirth='1941-05-24', |
74 |
place='Duluth', |
75 |
)
|
76 |
child1 = Child( |
77 |
lastname ='Zimmerman', |
78 |
firstname='Robert', |
79 |
sexe='M', |
80 |
birth=birth_info, |
81 |
)
|
82 |
results = client.service.updateFamily( |
83 |
dossierNumber = '196569', |
84 |
categorie='BI', |
85 |
situation='C', |
86 |
#rl1=rl1,
|
87 |
#rl2=rl2, # pour avoir une erreur mais je n'y arrive pas !
|
88 |
childList = [child1], # pour voir une erreur remontée par maélis MAIS mauvais format qui fait planter soap ! |
89 |
#nbChild=100, pour # test_update_family_soap_error (crash Maelis zeep.exceptions.Fault)
|
90 |
)
|
91 |
print(results) |