[IMP] Minimizes memory consumption

Conflicts:
	report_py3o/models/py3o_report.py
This commit is contained in:
Laurent Mignon
2016-12-23 12:43:57 +01:00
committed by Elmeri Niemelä
parent e69592c5f7
commit 714ea78ce8
2 changed files with 114 additions and 78 deletions

View File

@@ -5,6 +5,7 @@
import mock
import os
import pkg_resources
import tempfile
from py3o.formats import Formats
@@ -60,11 +61,17 @@ class TestReportPy3o(TransactionCase):
report = self.env.ref("report_py3o.res_users_report_py3o")
with mock.patch.object(
py3o_report.__class__, '_create_single_report') as patched_pdf:
result = tempfile.mktemp('.txt')
with open(result, 'w') as fp:
fp.write('dummy')
patched_pdf.return_value = result
# test the call the the create method inside our custom parser
report.render_report(self.env.user.ids,
report.report_name,
{})
self.assertEqual(1, patched_pdf.call_count)
# generated files no more exists
self.assertFalse(os.path.exists(result))
res = report.render_report(
self.env.user.ids, report.report_name, {})
self.assertTrue(res)