From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/website/tests/test_website_favicon.py | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 addons/website/tests/test_website_favicon.py (limited to 'addons/website/tests/test_website_favicon.py') diff --git a/addons/website/tests/test_website_favicon.py b/addons/website/tests/test_website_favicon.py new file mode 100644 index 00000000..3346ccd4 --- /dev/null +++ b/addons/website/tests/test_website_favicon.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from PIL import Image + +from odoo.tests import tagged +from odoo.tests.common import TransactionCase +from odoo.tools import base64_to_image, image_to_base64 + + +@tagged('post_install', '-at_install') +class TestWebsiteResetPassword(TransactionCase): + + def test_01_website_favicon(self): + """The goal of this test is to make sure the favicon is correctly + handled on the website.""" + + # Test setting an Ico file directly, done through create + Website = self.env['website'] + + website = Website.create({ + 'name': 'Test Website', + 'favicon': Website._default_favicon(), + }) + + image = base64_to_image(website.favicon) + self.assertEqual(image.format, 'ICO') + + # Test setting a JPEG file that is too big, done through write + bg_color = (135, 90, 123) + image = Image.new('RGB', (1920, 1080), color=bg_color) + website.favicon = image_to_base64(image, 'JPEG') + image = base64_to_image(website.favicon) + self.assertEqual(image.format, 'ICO') + self.assertEqual(image.size, (256, 256)) + self.assertEqual(image.getpixel((0, 0)), bg_color) -- cgit v1.2.3