Commit 705b4472 authored by Jérome Perrin's avatar Jérome Perrin

fixup! OOoUtils: deprecated openFromString in favor of openFromBytes WIP 🚧

parent 2dd8b34d
......@@ -3387,7 +3387,7 @@ class TestAccountingExport(AccountingTestCase):
form_id='AccountingTransaction_view')
from Products.ERP5OOo.OOoUtils import OOoParser
parser = OOoParser()
parser.openFromString(ods_data)
parser.openFromBytes(ods_data)
content_xml = parser.oo_files['content.xml']
# just make sure that we have the correct account name
self.assertEqual(
......
......@@ -20,11 +20,11 @@ def getSpreadsheet(file):
tmp_ooo.edit(data=file.read(), content_type=content_type)
tmp_ooo.convertToBaseFormat()
ignored, import_file_content = tmp_ooo.convert('ods')
ooo_parser.openFromString(str(import_file_content))
ooo_parser.openFromBytes(bytes(import_file_content))
else:
ooo_parser.openFile(file)
else:
ooo_parser.openFromString(file)
ooo_parser.openFromBytes(file)
return ooo_parser.getSpreadsheetsMapping()
......
......@@ -636,7 +636,7 @@ class TestInvoice(TestInvoiceMixin):
# the <draw:image> should not be present, because there's no logo
parser = OOoParser()
parser.openFromString(odt)
parser.openFromBytes(odt)
style_xml = parser.oo_files['styles.xml']
self.assertNotIn('<draw:image', style_xml)
......
......@@ -149,7 +149,7 @@ class TestOOoChart(TestOOoChartMixin):
from Products.ERP5OOo.OOoUtils import OOoParser
parser = OOoParser()
parser.openFromString(body)
parser.openFromBytess(body)
content_xml_view = parser.oo_files['content.xml']
doc_view = etree.fromstring(content_xml_view)
......@@ -243,7 +243,7 @@ class TestOOoChart(TestOOoChartMixin):
from Products.ERP5OOo.OOoUtils import OOoParser
parser = OOoParser()
parser.openFromString(body)
parser.openFromBytes(body)
content_xml_view = parser.oo_files['content.xml']
doc_view = etree.fromstring(content_xml_view)
......
......@@ -52,16 +52,17 @@ class TestOOoParser(unittest.TestCase):
self.assertEqual(person_mapping[1],
['John Doe 0', 'John', 'Doe 0', 'john.doe0@foo.com'])
def test_openFromString(self):
def test_openFromBytes(self):
parser = OOoParser()
parser.openFromString(
open(makeFilePath('import_data_list.ods'), 'rb').read())
with open(makeFilePath('import_data_list.ods'), 'rb') as f:
parser.openFromBytes(f.read())
mapping = parser.getSpreadsheetsMapping()
self.assertEqual(['Person'], list(mapping.keys()))
def test_getSpreadSheetMappingStyle(self):
parser = OOoParser()
parser.openFile(open(makeFilePath('import_data_list_with_style.ods'), 'rb'))
with open(makeFilePath('import_data_list_with_style.ods'), 'rb') as f:
parser.openFile(f)
mapping = parser.getSpreadsheetsMapping()
self.assertEqual(['Feuille1'], list(mapping.keys()))
self.assertEqual(mapping['Feuille1'][1],
......@@ -75,7 +76,8 @@ class TestOOoParser(unittest.TestCase):
def test_getSpreadSheetMappingDataTypes(self):
parser = OOoParser()
parser.openFile(open(makeFilePath('import_data_list_data_type.ods'), 'rb'))
with open(makeFilePath('import_data_list_data_type.ods'), 'rb') as f:
parser.openFile(f)
mapping = parser.getSpreadsheetsMapping()
self.assertEqual(['Feuille1'], list(mapping.keys()))
self.assertEqual(mapping['Feuille1'][0],
......
......@@ -454,7 +454,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
# Is it good to do this only for ODT ?
from Products.ERP5OOo.OOoUtils import OOoParser
parser = OOoParser()
parser.openFromString(body)
parser.openFromBytes(body)
content_xml = bytes2str(parser.oo_files['content.xml'])
self.assertIn('&lt;Escape&gt;&amp;<text:line-break/>newline', content_xml)
......@@ -484,7 +484,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
from Products.ERP5OOo.OOoUtils import OOoParser
parser = OOoParser()
parser.openFromString(body)
parser.openFromBytes(body)
content_xml = bytes2str(parser.oo_files['content.xml'])
self.assertIn(message, content_xml)
......
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