toulouse-maelis: accept empty referential (#74184) #84
|
@ -89,7 +89,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
|
||||
def update_referential(self, referential_name, data, id_key, text_key):
|
||||
last_update = now()
|
||||
for item in data:
|
||||
for item in data or []:
|
||||
text = item[text_key] or ''
|
||||
if isinstance(text, int):
|
||||
text = str(text)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:readApeIndicatorListResponse xmlns:ns2="ape.ws.maelis.sigec.com">
|
||||
<result/>
|
||||
</ns2:readApeIndicatorListResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -350,6 +350,20 @@ def test_update_referential(mocked_get, con):
|
|||
assert con.referential.filter(referential_name='Category').count() == 2
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
def test_update_referential_empty(mocked_get, con):
|
||||
mocked_get.return_value = APE_SERVICE_WSDL
|
||||
assert len(Referential.objects.filter(referential_name='ApeIndicator')) == 3
|
||||
|
||||
with mock.patch('passerelle.utils.Request.post') as mocked_post:
|
||||
mocked_post.return_value = FakedResponse(
|
||||
content=get_xml_file('R_read_ape_indicator_list_empty.xml'), status_code=200
|
||||
)
|
||||
data = con.get_referential_data('Ape', 'ApeIndicator')
|
||||
con.update_referential('ApeIndicator', data, 'level', 'level')
|
||||
assert len(Referential.objects.filter(referential_name='ApeIndicator')) == 0
|
||||
|
||||
|
||||
def test_cron(db):
|
||||
assert Referential.objects.filter(referential_name='Category').count() == 3
|
||||
assert sorted(list({x.referential_name for x in Referential.objects.all()})) == [
|
||||
|
|
Loading…
Reference in New Issue