110 |
110 |
title, ext = filename.split('.')
|
111 |
111 |
base64_data = 'VGVzdCBEb2N1bWVudA=='
|
112 |
112 |
data = {'type': typ, 'subtype': subtyp, 'visibility': visibility,
|
113 |
|
'title': title, 'data': base64_data, 'content-type':'application/pdf'}
|
114 |
|
url = reverse('generic-endpoint', kwargs={'connector': 'iparapheur',
|
115 |
|
'endpoint': 'create-file', 'slug': conn.slug})
|
116 |
|
resp = app.post_json(url, params=data, status=403)
|
117 |
|
url += '?apikey=%s' % API_KEY
|
118 |
|
resp = app.post_json(url, params=data)
|
119 |
|
# check output call args
|
120 |
|
assert (BASE_URL,) == mocked_post.call_args[0]
|
121 |
|
xml = ET.fromstring(mocked_post.call_args[1].get('data'))
|
122 |
|
req = xml.find('soap:Body', SOAP_NAMESPACES).find('ns1:CreerDossierRequest', SOAP_NAMESPACES)
|
123 |
|
assert req.find('ns1:DossierTitre', SOAP_NAMESPACES).text == title
|
124 |
|
assert req.find('ns1:DossierID', SOAP_NAMESPACES).text == title
|
125 |
|
assert req.find('ns1:TypeTechnique', SOAP_NAMESPACES).text == typ
|
126 |
|
assert req.find('ns1:SousType', SOAP_NAMESPACES).text == subtyp
|
127 |
|
assert req.find('ns1:Visibilite', SOAP_NAMESPACES).text == visibility
|
128 |
|
assert req.find('ns1:DocumentPrincipal', SOAP_NAMESPACES).text == base64_data
|
129 |
|
assert resp.json['data']['RecordId'] == file_id
|
130 |
|
|
|
113 |
'title': title}
|
|
114 |
|
|
115 |
for param_style in ('old_style', 'new_style'):
|
|
116 |
real_data = data.copy()
|
|
117 |
if param_style == 'old_style':
|
|
118 |
real_data.update({'data': base64_data, 'content-type':'application/pdf'})
|
|
119 |
else:
|
|
120 |
real_data.update({
|
|
121 |
'file': {
|
|
122 |
'content': base64_data, 'content_type':'application/pdf'
|
|
123 |
}
|
|
124 |
})
|
|
125 |
|
|
126 |
url = reverse('generic-endpoint', kwargs={'connector': 'iparapheur',
|
|
127 |
'endpoint': 'create-file', 'slug': conn.slug})
|
|
128 |
resp = app.post_json(url, params=real_data, status=403)
|
|
129 |
url += '?apikey=%s' % API_KEY
|
|
130 |
resp = app.post_json(url, params=real_data)
|
|
131 |
# check output call args
|
|
132 |
assert (BASE_URL,) == mocked_post.call_args[0]
|
|
133 |
xml = ET.fromstring(mocked_post.call_args[1].get('data'))
|
|
134 |
req = xml.find('soap:Body', SOAP_NAMESPACES).find('ns1:CreerDossierRequest', SOAP_NAMESPACES)
|
|
135 |
assert req.find('ns1:DossierTitre', SOAP_NAMESPACES).text == title
|
|
136 |
assert req.find('ns1:DossierID', SOAP_NAMESPACES).text == title
|
|
137 |
assert req.find('ns1:TypeTechnique', SOAP_NAMESPACES).text == typ
|
|
138 |
assert req.find('ns1:SousType', SOAP_NAMESPACES).text == subtyp
|
|
139 |
assert req.find('ns1:Visibilite', SOAP_NAMESPACES).text == visibility
|
|
140 |
assert req.find('ns1:DocumentPrincipal', SOAP_NAMESPACES).text == base64_data
|
|
141 |
assert resp.json['data']['RecordId'] == file_id
|
|
142 |
|
|
143 |
data = {
|
|
144 |
'type': typ, 'subtype': subtyp, 'visibility': visibility,
|
|
145 |
'title': title, 'data': base64_data, 'content-type':'application/pdf'
|
|
146 |
}
|
131 |
147 |
# KO
|
132 |
148 |
soap_response = """<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><CreerDossierResponse xmlns="http://www.adullact.org/spring-ws/iparapheur/1.0" xmlns:xmime="http://www.w3.org/2005/05/xmlmime"><MessageRetour><codeRetour>KO</codeRetour><message>KOmessage</message><severite>INFO</severite></MessageRetour></CreerDossierResponse></S:Body></S:Envelope>"""
|
133 |
149 |
response._content = soap_response
|
134 |
|
-
|