[MIG] report_qweb_encrypt: Migration to 15.0

This commit is contained in:
grzana12
2022-11-05 22:36:34 +01:00
parent cc30602e47
commit 048ddfd2b1
9 changed files with 151 additions and 144 deletions

View File

@@ -9,7 +9,7 @@ class TestReportQwebEncrypt(HttpCase):
ctx = {"force_report_rendering": True}
report = self.env.ref("web.action_report_internalpreview")
report.encrypt = False
pdf, _ = report.with_context(ctx)._render_qweb_pdf([1])
pdf, _ = report.with_context(**ctx)._render_qweb_pdf([1])
self.assertFalse(pdf.count(b"/Encrypt"))
def test_report_qweb_auto_encrypt(self):
@@ -17,16 +17,33 @@ class TestReportQwebEncrypt(HttpCase):
report = self.env.ref("web.action_report_internalpreview")
report.encrypt = "auto"
report.encrypt_password = False
# If no encrypt_password, still not encrypted
pdf, _ = report.with_context(ctx)._render_qweb_pdf([1])
pdf, _ = report.with_context(**ctx)._render_qweb_pdf([1])
self.assertFalse(pdf.count(b"/Encrypt"))
# If invalid encrypt_password, show error
report.encrypt_password = "invalid python syntax"
with self.assertRaises(ValidationError):
pdf, _ = report.with_context(ctx)._render_qweb_pdf([1])
pdf, _ = report.with_context(**ctx)._render_qweb_pdf([1])
# Valid python string for password
report.encrypt_password = "'secretcode'"
pdf, _ = report.with_context(ctx)._render_qweb_pdf([1])
pdf, _ = report.with_context(**ctx)._render_qweb_pdf([1])
self.assertTrue(pdf.count(b"/Encrypt"))
def test_report_qweb_manual_encrypt(self):
ctx = {"force_report_rendering": True}
report = self.env.ref("web.action_report_internalpreview")
report.encrypt = "manual"
# If no encrypt_password, still not encrypted
pdf, _ = report.with_context(**ctx)._render_qweb_pdf([1])
self.assertFalse(pdf.count(b"/Encrypt"))
# Valid python string for password
ctx.update({"encrypt_password": "secretcode"})
pdf, _ = report.with_context(**ctx)._render_qweb_pdf([1])
self.assertTrue(pdf.count(b"/Encrypt"))
# TODO: test_report_qweb_manual_encrypt, require JS test?