parent
05905b794e
commit
68f14c6870
|
@ -210,9 +210,6 @@ class test_preview(TransactionCase):
|
||||||
})
|
})
|
||||||
self.assertTrue('error' in result)
|
self.assertTrue('error' in result)
|
||||||
|
|
||||||
def test_csv_errors(self):
|
|
||||||
Import, id = self.make_import()
|
|
||||||
|
|
||||||
result = Import.parse_preview(self.cr, self.uid, id, {
|
result = Import.parse_preview(self.cr, self.uid, id, {
|
||||||
'quoting': '"',
|
'quoting': '"',
|
||||||
'separator': 'bob',
|
'separator': 'bob',
|
||||||
|
@ -356,3 +353,32 @@ class test_convert_import_data(TransactionCase):
|
||||||
Import._convert_import_data,
|
Import._convert_import_data,
|
||||||
record, [False, False, False],
|
record, [False, False, False],
|
||||||
{'quoting': '"', 'separator': ',', 'headers': True,})
|
{'quoting': '"', 'separator': ',', 'headers': True,})
|
||||||
|
|
||||||
|
class test_failures(TransactionCase):
|
||||||
|
def test_big_attachments(self):
|
||||||
|
"""
|
||||||
|
Ensure big fields (e.g. b64-encoded image data) can be imported and
|
||||||
|
we're not hitting limits of the default CSV parser config
|
||||||
|
"""
|
||||||
|
import csv, cStringIO
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
im = Image.new('RGB', (1920, 1080))
|
||||||
|
fout = cStringIO.StringIO()
|
||||||
|
|
||||||
|
writer = csv.writer(fout, dialect=None)
|
||||||
|
writer.writerows([
|
||||||
|
['name', 'db_datas'],
|
||||||
|
['foo', im.tobytes().encode('base64')]
|
||||||
|
])
|
||||||
|
|
||||||
|
Import = self.env['base_import.import']
|
||||||
|
imp = Import.create({
|
||||||
|
'res_model': 'ir.attachment',
|
||||||
|
'file': fout.getvalue()
|
||||||
|
})
|
||||||
|
[results] = imp.do(
|
||||||
|
['name', 'db_datas'],
|
||||||
|
{'headers': True, 'separator': ',', 'quoting': '"'})
|
||||||
|
self.assertFalse(
|
||||||
|
results, "results should be empty on successful import")
|
||||||
|
|
|
@ -30,6 +30,7 @@ GNU Public Licence.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
|
import csv
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
|
@ -142,6 +143,11 @@ def main(args):
|
||||||
|
|
||||||
config = openerp.tools.config
|
config = openerp.tools.config
|
||||||
|
|
||||||
|
# the default limit for CSV fields in the module is 128KiB, which is not
|
||||||
|
# quite sufficient to import images to store in attachment. 500MiB is a
|
||||||
|
# bit overkill, but better safe than sorry I guess
|
||||||
|
csv.field_size_limit(500 * 1024 * 1024)
|
||||||
|
|
||||||
if config["test_file"]:
|
if config["test_file"]:
|
||||||
config["test_enable"] = True
|
config["test_enable"] = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue