TG-62 upload file (template) => test
This commit is contained in:
parent
7a9f64c529
commit
fb75b05d1b
@ -53,14 +53,14 @@ def allowed_file(filename):
|
||||
filename.rsplit('.', 1)[1].lower() in allowed_extensions
|
||||
|
||||
|
||||
def upload_file(file, upload_folder):
|
||||
def upload_file(file_to_upload, upload_folder):
|
||||
"""
|
||||
rep de l'etu avec id
|
||||
:param file:
|
||||
:param upload_folder:
|
||||
:return:
|
||||
"""
|
||||
file.save(secure_filename(os.path.join(upload_folder, file.filename)))
|
||||
file_to_upload.save(os.path.join(upload_folder, secure_filename(file_to_upload.filename)))
|
||||
|
||||
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from builtins import print
|
||||
from pathlib import Path
|
||||
|
||||
from app.tools.FusionPdf import fusion_fichiers, get_pdf_from_directory
|
||||
|
BIN
backend/tests/tools/libPdf/UploadPDF/page1.pdf
Normal file
BIN
backend/tests/tools/libPdf/UploadPDF/page1.pdf
Normal file
Binary file not shown.
20
backend/tests/tools/libPdf/UploadPDF/testUploadPdf.py
Normal file
20
backend/tests/tools/libPdf/UploadPDF/testUploadPdf.py
Normal file
@ -0,0 +1,20 @@
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from werkzeug.datastructures import FileStorage
|
||||
|
||||
from app.tools.LibPdf import upload_file
|
||||
|
||||
|
||||
class TestFusionTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.datadir = os.path.join(os.path.dirname(__file__))
|
||||
|
||||
def test_fusion(self):
|
||||
with open("page1.pdf", 'rb') as fp:
|
||||
file = FileStorage(fp)
|
||||
upload_file(file, "upload")
|
||||
|
||||
# self.assertTrue(Path(self.datadir + "/testFusion.pdf").is_file(), "Pdf fusionne inexistant")
|
||||
# self.assertTrue(len(get_pdf_from_directory(self.datadir)) > 0, "pdf non trouve")
|
||||
# os.remove(self.datadir + "/testFusion.pdf")
|
0
backend/tests/tools/libPdf/pdfjinja/__init__.py
Normal file
0
backend/tests/tools/libPdf/pdfjinja/__init__.py
Normal file
@ -3,9 +3,8 @@ import unittest
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
|
||||
from pdfjinja import PdfJinja
|
||||
|
||||
from app.tools.InsertTemplate import remplir_template
|
||||
from pdfjinja import PdfJinja
|
||||
|
||||
|
||||
class InsertTemplateTestCase(unittest.TestCase):
|
Reference in New Issue
Block a user