<commit_before># Copyright 2015-2017
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

import odoo.tests.common as common
from odoo import exceptions


class TestBaseReportAutoQwebCreate(common.TransactionCase):
    def setUp(self):
        super(TestBaseReportAutoQwebCreate, self).setUp()
        self.report_model = self.env["ir.actions.report"]
        self.duplicate_model = self.env["ir.actions.report.duplicate"]
        self.view_model = self.env["ir.ui.view"]

    def test_creation_html(self):
        report_html = self.report_model.create(
            {
                "name": "<NAME>",
                "model": "res.partner",
                "report_type": "qweb-html",
                "report_name": "test1.report_test",
            }
        )
        report_html.button_create_qweb()
        view_num = self.view_model.search_count(
            [
                ("name", "ilike", report_html.report_name.split(".")[1]),
                ("type", "=", "qweb"),
            ]
        )
        self.assertNotEqual(view_num, 0, "There are not related views")
        self.assertEqual(view_num, 1, "Only one view must be created.")

    def test_creation_duplicate_pdf(self):
        report_pdf = self.report_model.create(
            {
                "name": "<NAME>",
                "model": "res.partner",
                "report_type": "qweb-pdf",
                "report_name": "test2.report_test",
            }
        )
        report_pdf.button_create_qweb()
        view_num = self.view_model.search_count(
            [
                ("name", "ilike", report_pdf.report_name.split(".")[1]),
                ("type", "=", "qweb"),
            ]
        )
        self.assertNotEqual(view_num, 0, "There are not related views.")
        self.assertEqual(view_num, 1, "One view must be created.")
        wizard = self.duplicate_model.with_context(
            active_id=report_pdf.id, model=report_pdf.model
        ).create(
            {
                "suffix": "copytest",
            }
        )
        wizard.duplicate_report()
        report_pdf_copies = self.report_model.search(
            [("report_name", "ilike", "test2_copytest.report_test_copytest")]
        )
        for report_pdf_copy in report_pdf_copies:
            view_num2 = self.view_model.search_count(
                [
                    ("name", "ilike", report_pdf_copy.report_name.split(".")[1]),
                    ("type", "=", "qweb"),
                ]
            )
            self.assertNotEqual(view_num2, 0, "There are not related views.")
            self.assertEqual(<commit_msg>[14.0][FIX] base_report_auto_create_qweb-conflict_test_report, conflict test report name<commit_after># Copyright 2015-2017
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

import odoo.tests.common as common
from odoo import exceptions


class TestBaseReportAutoQwebCreate(common.TransactionCase):
    def setUp(self):
        super(TestBaseReportAutoQwebCreate, self).setUp()
        self.report_model = self.env["ir.actions.report"]
        self.duplicate_model = self.env["ir.actions.report.duplicate"]
        self.view_model = self.env["ir.ui.view"]

    def test_creation_html(self):
        report_html = self.report_model.create(
            {
                "name": "<NAME>",
                "model": "res.partner",
                "report_type": "qweb-html",
                "report_name": "test1.auto_qweb_report_test",
            }
        )
        report_html.button_create_qweb()
        view_num = self.view_model.search_count(
            [
                ("name", "ilike", report_html.report_name.split(".")[1]),
                ("type", "=", "qweb"),
            ]
        )
        self.assertNotEqual(view_num, 0, "There are not related views")
        self.assertEqual(view_num, 1, "Only one view must be created.")

    def test_creation_duplicate_pdf(self):
        report_pdf = self.report_model.create(
            {
                "name": "<NAME>",
                "model": "res.partner",
                "report_type": "qweb-pdf",
                "report_name": "test2.auto_qweb_report_test",
            }
        )
        report_pdf.button_create_qweb()
        view_num = self.view_model.search_count(
            [
                ("name", "ilike", report_pdf.report_name.split(".")[1]),
                ("type", "=", "qweb"),
            ]
        )
        self.assertNotEqual(view_num, 0, "There are not related views.")
        self.assertEqual(view_num, 1, "One view must be created.")
        wizard = self.duplicate_model.with_context(
            active_id=report_pdf.id, model=report_pdf.model
        ).create(
            {
                "suffix": "copytest",
            }
        )
        wizard.duplicate_report()
        report_pdf_copies = self.report_model.search(
            [("report_name", "ilike", "test2_copytest.report_test_copytest")]
        )
        for report_pdf_copy in report_pdf_copies:
            view_num2 = self.view_model.search_count(
                [
                    ("name", "ilike", report_pdf_copy.report_name.split(".")[1]),
                    ("type", "=", "qweb"),
                ]
            )
            self.assertNotEqual(view_num2, 0, "There are not related views.")
            self.assertEqual(
{'fraction_non_alphanumeric': 0.1288688801350591, 'fraction_numerical': 0.009566685424873381, 'mean_word_length': 1.8697524219590957, 'pattern_counts': {'":': 18, '<': 7, '<?xml version=': 0, '>': 7, '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': '6616081', 'n_tokens_mistral': 1652, 'n_tokens_neox': 1584, 'n_words': 260}