0001-dpark-pass-file-s-raw-content-to-zeep-26417.patch
passerelle/contrib/dpark/models.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
import base64 |
|
17 | 18 |
import json |
18 | 19 | |
19 | 20 |
from django.conf import settings |
... | ... | |
399 | 400 |
errors.extend(value_errors) |
400 | 401 |
continue |
401 | 402 | |
403 |
# use raw content because to prevent zeep |
|
404 |
# from encoding the content into base64 a second time. |
|
405 |
file_raw_content = base64.b64decode(value['content']) |
|
402 | 406 |
attached_files.append({ |
403 |
'TypeDocument': doc_id, 'NomFichier': value['filename'], 'Fichier': value['content']})
|
|
407 |
'TypeDocument': doc_id, 'NomFichier': value['filename'], 'Fichier': file_raw_content})
|
|
404 | 408 |
# deduce the number of files |
405 | 409 |
if errors: |
406 | 410 |
raise APIError(errors) |
tests/test_dpark.py | ||
---|---|---|
487 | 487 |
'content': base64.b64encode('this is my proof of address')} |
488 | 488 |
params['cartegrise,1'] = { |
489 | 489 |
'filename': 'cartegrise.pdf', 'content_type': 'application/pdf', |
490 |
'content': base64.b64encode('whatever')
|
|
490 |
'content': base64.b64encode('carte grise 1')
|
|
491 | 491 |
} |
492 | 492 |
params['toto,6'] = { |
493 | 493 |
'filename': 'cartegrisetoto.pdf', 'content_type': 'application/pdf', |
... | ... | |
495 | 495 |
} |
496 | 496 |
params['cartegrise,6'] = { |
497 | 497 |
'filename': 'cartegrise2.pdf', 'content_type': 'application/pdf', |
498 |
'content': base64.b64encode('whatever')
|
|
498 |
'content': base64.b64encode('carte grise 2')
|
|
499 | 499 |
} |
500 | 500 |
params['taxe_habitat'] = { |
501 | 501 |
'filename': 'cartegrise2.pdf', 'content_type': 'application/pdf', |
... | ... | |
529 | 529 |
assert len(soap_call.call_args[0][4]) == 4 |
530 | 530 |
assert soap_call.call_args[0][4][0]['NomFichier'] == 'cartegrise.pdf' |
531 | 531 |
assert soap_call.call_args[0][4][0]['TypeDocument'] == '6' |
532 |
assert soap_call.call_args[0][4][0]['Fichier'] == 'carte grise 1' |
|
532 | 533 |
assert soap_call.call_args[0][4][1]['NomFichier'] == 'cartegrise2.pdf' |
533 | 534 |
assert soap_call.call_args[0][4][1]['TypeDocument'] == '6' |
535 |
assert soap_call.call_args[0][4][1]['Fichier'] == 'carte grise 2' |
|
534 |
- |