Commit 95eb437e authored by Tristan Cavelier's avatar Tristan Cavelier

x2t: update tests

parent 7658d236
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
import magic import magic
import os.path import os.path
from zipfile import ZipFile
from cStringIO import StringIO
from cloudooo.handler.x2t.handler import Handler from cloudooo.handler.x2t.handler import Handler
from cloudooo.tests.handlerTestCase import HandlerTestCase, make_suite from cloudooo.tests.handlerTestCase import HandlerTestCase, make_suite
...@@ -40,7 +42,8 @@ class TestHandler(HandlerTestCase): ...@@ -40,7 +42,8 @@ class TestHandler(HandlerTestCase):
def testConvertXlsx(self): def testConvertXlsx(self):
"""Test conversion of xlsx to xlsy and back""" """Test conversion of xlsx to xlsy and back"""
y_data = Handler(self.tmp_url, open("data/test.xlsx").read(), "xlsx", **self.kw).convert("xlsy") y_data = Handler(self.tmp_url, open("data/test.xlsx").read(), "xlsx", **self.kw).convert("xlsy")
self.assertTrue(y_data.startswith("XLSY;v2;5883;"), "%r... does not start with 'XLSY;v2;5883;'" % (y_data[:20],)) y_body_data = ZipFile(StringIO(y_data)).open("body.txt").read()
self.assertTrue(y_body_data.startswith("XLSY;v2;5883;"), "%r... does not start with 'XLSY;v2;5883;'" % (y_body_data[:20],))
x_data = Handler(self.tmp_url, y_data, "xlsy", **self.kw).convert("xlsx") x_data = Handler(self.tmp_url, y_data, "xlsy", **self.kw).convert("xlsx")
# magic inspired by https://github.com/minad/mimemagic/pull/19/files # magic inspired by https://github.com/minad/mimemagic/pull/19/files
...@@ -52,7 +55,8 @@ class TestHandler(HandlerTestCase): ...@@ -52,7 +55,8 @@ class TestHandler(HandlerTestCase):
self.assertIn("xl/", x_data[:2000]) self.assertIn("xl/", x_data[:2000])
y_data = Handler(self.tmp_url, x_data, "xlsx", **self.kw).convert("xlsy") y_data = Handler(self.tmp_url, x_data, "xlsx", **self.kw).convert("xlsy")
self.assertTrue(y_data.startswith("XLSY;v2;10579;"), "%r... does not start with 'XLSY;v2;10579;'" % (y_data[:20],)) y_body_data = ZipFile(StringIO(y_data)).open("body.txt").read()
self.assertTrue(y_body_data.startswith("XLSY;v2;10579;"), "%r... does not start with 'XLSY;v2;10579;'" % (y_body_data[:20],))
def testgetMetadataFromImage(self): def testgetMetadataFromImage(self):
"""Test getMetadata not implemented form yformats""" """Test getMetadata not implemented form yformats"""
......
...@@ -33,7 +33,7 @@ class TestServer(TestCase): ...@@ -33,7 +33,7 @@ class TestServer(TestCase):
def ConversionScenarioList(self): def ConversionScenarioList(self):
return [ return [
(join('data', 'test.xlsx'), "xlsx", "xlsy", "text/plain"), # XXX no mime mapping for xlsy ? (join('data', 'test.xlsx'), "xlsx", "xlsy", "application/zip"),
(join('data', 'test.xlsy'), "xlsy", "xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), (join('data', 'test.xlsy'), "xlsy", "xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
] ]
......
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