Commit 958c7242 authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor test and use python-magic if the function getContent() returns the document expected

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@42218 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent adfd9071
...@@ -118,20 +118,17 @@ class TestFileSystemDocument(unittest.TestCase): ...@@ -118,20 +118,17 @@ class TestFileSystemDocument(unittest.TestCase):
def testSendZipFile(self): def testSendZipFile(self):
"""Tests if the htm is extrated from zipfile""" """Tests if the htm is extrated from zipfile"""
# XXX it seems that only zipfile module is tested here
zip_input_url = 'data/test.zip' zip_input_url = 'data/test.zip'
zip_output_url = path.join(self.tmp_url, 'zipdocument.zip') data = open(zip_input_url).read()
try: zipdocument = FileSystemDocument(self.tmp_url, data, 'zip')
data = open(zip_input_url).read() mime = magic.Magic(mime=True)
zipdocument = FileSystemDocument(self.tmp_url, data, 'zip') mimetype = mime.from_buffer(zipdocument.getContent(True))
open(zip_output_url, 'w').write(zipdocument.getContent(True)) self.assertEquals(mimetype, "application/zip")
self.assertTrue(is_zipfile(zip_output_url)) mimetype = mime.from_buffer(zipdocument.getContent())
zipfile = ZipFile(zip_output_url) self.assertEquals(mimetype, "text/html")
self.assertEquals(sorted(zipfile.namelist()), zipfile = ZipFile(StringIO(zipdocument.getContent(True)))
sorted(['logo.gif', 'test.htm'])) self.assertEquals(sorted(zipfile.namelist()),
finally: sorted(['logo.gif', 'test.htm']))
if path.exists(zip_output_url):
remove(zip_output_url)
def test_suite(): def test_suite():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment