summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2021-05-13 07:15:24 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2021-05-13 07:15:24 (GMT)
commit156ff794f40161554a2259f995af0684cdf10fa4 (patch)
tree583ced4d84631a1b3e09b8a550b6f5ec6e52f2b1
parent43c7cf6fcc9a2d5c4f22709377d0fa953ccf02ca (diff)
downloadpasserelle-atreal-openads-156ff794f40161554a2259f995af0684cdf10fa4.zip
passerelle-atreal-openads-156ff794f40161554a2259f995af0684cdf10fa4.tar.gz
passerelle-atreal-openads-156ff794f40161554a2259f995af0684cdf10fa4.tar.bz2
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/
-rw-r--r--tests/conftest.py6
-rw-r--r--tests/test_atreal_openads.py2
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