This repository has been archived on 2021-09-15. You can view files and clone it, but cannot push or open issues or pull requests.

26 lines
767 B
Python
Raw Permalink Normal View History

2017-03-31 12:28:00 +02:00
import filecmp
2017-03-28 18:04:57 +02:00
import os
import unittest
2017-03-31 12:28:00 +02:00
from pathlib import Path
2017-03-28 18:04:57 +02:00
from werkzeug.datastructures import FileStorage
2017-03-31 12:28:00 +02:00
from app.tools.LibPdf import upload_file, allowed_file
2017-03-28 18:04:57 +02:00
class TestFusionTestCase(unittest.TestCase):
def setUp(self):
2017-03-31 12:28:00 +02:00
self.datadir = "upload/page1.pdf"
self.file_name = "page1.pdf"
2017-03-28 18:04:57 +02:00
def test_fusion(self):
2017-03-31 12:28:00 +02:00
with open(self.file_name, 'rb') as fp:
2017-03-28 18:04:57 +02:00
file = FileStorage(fp)
upload_file(file, "upload")
2017-03-31 12:28:00 +02:00
self.assertTrue(Path(self.datadir).is_file(), "Pdf upload inexistant")
self.assertTrue(filecmp.cmp(self.datadir, self.file_name), "fichiers non identique")
self.assertTrue(allowed_file(self.file_name), "format non conforme")
os.remove(self.datadir)