<commit_before># -*- coding: utf-8 -*-
# © 2016 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from PIL import Image
from openerp.tests.common import HttpCase


class TestReportQwebPdfWatermark(HttpCase):
    def test_report_qweb_pdf_watermark(self):
        Image.init()
        # with our image, we have three
        self._test_report_images(3)

        self.env.ref('report_qweb_pdf_watermark.demo_report').write({
            'pdf_watermark_expression': False,
        })
        # without, we have two
        self._test_report_images(2)

        self.env.ref('report_qweb_pdf_watermark.demo_report').write({
            'pdf_watermark': self.env.user.company_id.logo,
        })
        # and now we should have three again
        self._test_report_images(3)

    def _test_report_images(self, number):
        pdf = self.env['report'].get_pdf(
            self.env['res.users'].search([]).ids,
            'report_qweb_pdf_watermark.demo_report_view',
        )
        self.assertEqual(pdf.count('/Subtype /Image'), number)<commit_msg>fix test_report_qweb_signer - tests were causing travis to stall<commit_after># -*- coding: utf-8 -*-
# © 2016 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from PIL import Image
from odoo.tests.common import HttpCase


class TestReportQwebPdfWatermark(HttpCase):
    def test_report_qweb_pdf_watermark(self):
        Image.init()
        # with our image, we have three
        self._test_report_images(3)

        self.env.ref('report_qweb_pdf_watermark.demo_report').write({
            'pdf_watermark_expression': False,
        })
        # without, we have two
        self._test_report_images(2)

        self.env.ref('report_qweb_pdf_watermark.demo_report').write({
            'pdf_watermark': self.env.user.company_id.logo,
        })
        # and now we should have three again
        self._test_report_images(3)

    def _test_report_images(self, number):
        pdf = self.env['report'].get_pdf(
            self.env['res.users'].search([]).ids,
            'report_qweb_pdf_watermark.demo_report_view',
        )
        self.assertEqual(pdf.count('/Subtype /Image'), number)
{'fraction_non_alphanumeric': 0.12209302325581395, 'fraction_numerical': 0.008944543828264758, 'mean_word_length': 2.765993265993266, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4627010', 'n_tokens_mistral': 729, 'n_tokens_neox': 721, 'n_words': 130}