greco: add more tests (#51623)

This commit is contained in:
Nicolas Roche 2021-03-05 17:18:26 +01:00 committed by Frédéric Péters
parent c137e7be68
commit 083cef16c9
5 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ajouterComplementInformationResponse xmlns="http://mairies.services.external.coheris.com">
<ajouterComplementInformationReturn>
<iddemande>MDFGDZRF</iddemande>
<idgreco>538593</idgreco>
<motifsrejet>Le complément d\'information ne peut être ajouté qu\'à une demande ayant le statut \'incomplète\'\r\n</motifsrejet>
</ajouterComplementInformationReturn>
</ajouterComplementInformationResponse>
</soapenv:Body>
</soapenv:Envelope>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ajouterComplementInformationResponse xmlns="http://mairies.services.external.coheris.com">
<ajouterComplementInformationReturn>
<iddemande>ZHRNMWVP</iddemande>
<idgreco>538634</idgreco>
<motifsrejet/>
</ajouterComplementInformationReturn>
</ajouterComplementInformationResponse>
</soapenv:Body>
</soapenv:Envelope>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<relancerResponse xmlns="http://mairies.services.external.coheris.com">
<relancerReturn>
<iddemande>MDFGDZRF</iddemande>
<idgreco>538593</idgreco>
<motifsrejet>La date de résolution prévue pour la demande 538593 n\'est pas dépassée\r\n</motifsrejet>
</relancerReturn>
</relancerResponse>
</soapenv:Body>
</soapenv:Envelope>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<relancerResponse xmlns="http://mairies.services.external.coheris.com">
<relancerReturn>
<iddemande>KPZDXCLL</iddemande>
<idgreco>538640</idgreco>
<motifsrejet/>
</relancerReturn>
</relancerResponse>
</soapenv:Body>
</soapenv:Envelope>

View File

@ -63,6 +63,10 @@ STATUS_OK = fake_xml_response('status_ok')
STATUS_KO = fake_xml_response('status_ko')
ANSWER_OK = fake_xml_response('answer_ok')
ANSWER_KO = fake_xml_response('answer_ko')
ADD_INFORMATION_OK = fake_xml_response('add_information_ok')
ADD_INFORMATION_KO = fake_xml_response('add_information_ko')
UPDATE_OK = fake_xml_response('update_ok')
UPDATE_KO = fake_xml_response('update_ko')
CREATE_PAYLOAD = {
'datecreation': '2021-03-02T14:44:38',
@ -294,3 +298,63 @@ def test_greco_answer_ko(mocked_post, app, conn):
'etat': None,
'message': {'bcc': None, 'cc': None, 'content': None, 'date': None, 'subject': None, 'to': None},
}
@mock.patch('passerelle.utils.Request.post', side_effect=(TOKEN, ADD_INFORMATION_OK))
def test_greco_add_information_ok(mocked_post, app, conn):
url = reverse(
'generic-endpoint', kwargs={'connector': 'greco', 'endpoint': 'add-information', 'slug': conn.slug}
)
url += '?apikey=grecokey'
resp = app.get(url, params={'idgreco': '538634', 'iddemande': 'ZHRNMWVP', 'information': 'my info'})
assert not resp.json['err']
assert resp.json['data'] == {
'iddemande': 'ZHRNMWVP',
'idgreco': '538634',
'motifsrejet': None,
}
@mock.patch('passerelle.utils.Request.post', side_effect=(TOKEN, ADD_INFORMATION_KO))
def test_greco_add_information_ko(mocked_post, app, conn):
url = reverse(
'generic-endpoint', kwargs={'connector': 'greco', 'endpoint': 'add-information', 'slug': conn.slug}
)
url += '?apikey=grecokey'
resp = app.get(url, params={'idgreco': '538593', 'iddemande': 'MDFGDZRF', 'information': 'my info'})
assert not resp.json['err']
assert resp.json['data'] == {
"iddemande": "MDFGDZRF",
"idgreco": "538593",
"motifsrejet": "Le complément d\\'information ne peut être ajouté qu\\'à une demande ayant le statut \\'incomplète\\'\\r\\n",
}
@mock.patch('passerelle.utils.Request.post', side_effect=(TOKEN, UPDATE_OK))
def test_greco_update_ok(mocked_post, app, conn):
url = reverse('generic-endpoint', kwargs={'connector': 'greco', 'endpoint': 'update', 'slug': conn.slug})
url += '?apikey=grecokey'
resp = app.get(url, params={'idgreco': '538640', 'iddemande': 'KPZDXCLL', 'comment': 'my comment'})
assert not resp.json['err']
assert resp.json['data'] == {
'iddemande': 'KPZDXCLL',
'idgreco': '538640',
'motifsrejet': None,
}
@mock.patch('passerelle.utils.Request.post', side_effect=(TOKEN, UPDATE_KO))
def test_greco_update_ko(mocked_post, app, conn):
url = reverse('generic-endpoint', kwargs={'connector': 'greco', 'endpoint': 'update', 'slug': conn.slug})
url += '?apikey=grecokey'
resp = app.get(url, params={'idgreco': '538593', 'iddemande': 'MDFGDZRF', 'comment': 'my comment'})
assert not resp.json['err']
assert resp.json['data'] == {
'iddemande': 'MDFGDZRF',
'idgreco': '538593',
'motifsrejet': "La date de résolution prévue pour la demande 538593 n\\'est pas dépassée\\r\\n",
}