summaryrefslogtreecommitdiff
path: root/addons/website/tests/test_website_favicon.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/website/tests/test_website_favicon.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/website/tests/test_website_favicon.py')
-rw-r--r--addons/website/tests/test_website_favicon.py36
1 files changed, 36 insertions, 0 deletions
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)