API Documentation¶
Odoo Assertions¶
High level Odoo assertions.
-
class
odoo_report_testing.assertions.
OdooAssertions
[source]¶ Mixin class providing assertion and helper methods to write tests.
-
assertImage
(ref, compared, msg=None, output_dir=None)[source]¶ Test if two images are equals, if not, this generate a diff file and a animated gif file to highlight differences.
It could be two single page pdf files.
This delegate the work to
compare
application installed with imagemagick package which is required.Parameters: - ref – a
path
to the file used as reference, expected result - compared – a
path
to the file to compare to the ref file. - msg – A message to print in case of faillure
Output_dir: Directory to generate diff files
- ref – a
-
assertOdooReport
(reference, model, report_service_name, ids, data=None, context=None)[source]¶ Generate report and compare to a reference file, test will failed if files are different, have a look close to the reference file you will find a diff picture that show you differences.
here an example to test sale order quotation report:
# -*- coding: utf-8 -*- import os from openerp.tests.common import TransactionCase from odoo_report_testing.assertions import OdooAssertions class TestSoReport(TransactionCase, OdooAssertions): def test_simple_so_report(self): self.assertOdooReport( os.path.join( os.path.dirname(__file__), 'expected_reports', 'test_so_report.pdf' ), 'sale.order', 'sale.report_saleorder', [self.ref('sale.sale_order_1')], data={}, context=None )
Warning
You may want to generate those report without expose any odoo port so that you can render report properly without http access.
- You can follow this PR:
Parameters: - reference – Path to the report that the generated report should looks like
- model – fully qualified model name
- report_service_name – report name (without report.)
- ids – object used to generate the report
- data – extra data given to draw the report
- context – odoo context
-
Pdf tools¶
-
class
odoo_report_testing.reports.
pdftools
[source]¶ Utility class to generate pdf file from odoo record, compare 2 pdf files
-
static
generateReport
(cr, uid, model, report_service_name, ids, data=None, context=None, version7=False)[source]¶ Generate the report and return it as a tuple (result, format) where result is the report document and format is the file extension.
-
static
imagediff
(ref, compared, output_dir=None)[source]¶ Test if two images are equals, if not, this generate a diff file and a animated gif file to highlight differences.
It can be two single page pdf file.
This delegate the work to
compare
application installed with imagemagick package which is required.Parameters: - ref – a
path
to the file used as reference, expected result - compared – a
path
to the file to compare to the ref file.
Output_dir: Directory to generate diff files
return (Boolean equals, [String path to diff files,]): The result is a a tuple with bool value to tell if files are equals or not, and a list of diff files generated.
- ref – a
-
static