From 156ff794f40161554a2259f995af0684cdf10fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 13 May 2021 09:15:24 +0200 Subject: [PATCH] tests: give an explicit name when creating files (#53755) Django 2.2.21 introduced the validation of FieldFile.save() name argument, which cannot contain a path separator anymore. ref. https://docs.djangoproject.com/en/3.2/releases/2.2.21/ --- tests/conftest.py | 6 ++++-- tests/test_atreal_openads.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 4b030d3..691f558 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -182,7 +182,8 @@ def forwardfile_1(fake_conf, db, atreal_openads, collectivite_1): orig_filename=os.path.basename(fake_conf['TEST_FILE_CERFA_DIA']), content_type='application/pdf', file_hash='ffdf456fdsvgb4bgfb6g4f5b', - upload_file=File(open(fake_conf['TEST_FILE_CERFA_DIA'], 'rb')), + upload_file=File(open(fake_conf['TEST_FILE_CERFA_DIA'], 'rb'), + name=os.path.basename(fake_conf['TEST_FILE_CERFA_DIA'])), upload_status='pending' ) @@ -200,7 +201,8 @@ def forwardfile_2(fake_conf, connecteur=None, collectivite=None): orig_filename=os.path.basename(fake_conf['TEST_FILE_CERFA_DIA']), content_type='application/pdf', file_hash='ffdf456fdsvgb4bgfb6g4f5b', - upload_file=File(open(fake_conf['TEST_FILE_CERFA_DIA'], 'rb')), + upload_file=File(open(fake_conf['TEST_FILE_CERFA_DIA'], 'rb'), + name=os.path.basename(fake_conf['TEST_FILE_CERFA_DIA'])), upload_status='pending' ) diff --git a/tests/test_atreal_openads.py b/tests/test_atreal_openads.py index 73fd769..e540e08 100644 --- a/tests/test_atreal_openads.py +++ b/tests/test_atreal_openads.py @@ -76,7 +76,7 @@ def build_forwardfile_from_path(connecteur, path, numero_dossier, type_fichier): fwd_file.content_type = magic.from_file(path, mime=True) with open(path, 'rb') as file_pt: fwd_file.file_hash = get_file_digest(file_pt) - fwd_file.upload_file = File(open(path, 'rb')) + fwd_file.upload_file = File(open(path, 'rb'), name=fwd_file.orig_filename) fwd_file.upload_status = 'pending' return fwd_file return None