diff options
| author | Sébastien Theys <seb@odoo.com> | 2019-02-18 09:43:06 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2019-02-18 09:43:06 +0000 |
| commit | 13026546463788852b79d23fde488308023f20a8 (patch) | |
| tree | e61c3a74c09240aae66324f4632f9f92a6eec0f6 /addons/web | |
| parent | 539fb375e18fc49ad2d53cbb612604dd8aeb6e73 (diff) | |
[IMP] base,web,website_sale: add tests for product image and mixin
This commit will add tests for the PR #30656 which added the following commit:
7daa85dd12ff522be510bc2f8db1d968cae7d891
The tests in the current commit achieve 100% code coverage for:
- the `image.mixin`
- the overridden `image.mixin` methods in `product.product`
- the `_get_images` methods of ecommerce
- the size logic in method `content_image` (route `/web/image`)
PR: #31181
Diffstat (limited to 'addons/web')
| -rw-r--r-- | addons/web/tests/test_image.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/addons/web/tests/test_image.py b/addons/web/tests/test_image.py index 96e09444c05..e17073d0fb7 100644 --- a/addons/web/tests/test_image.py +++ b/addons/web/tests/test_image.py @@ -10,10 +10,35 @@ from odoo.tests.common import HttpCase class TestImage(HttpCase): def test_01_content_image_resize_placeholder(self): + """The goal of this test is to make sure the placeholder image is + resized appropriately depending on the given URL parameters.""" + + # CASE: resize placeholder to given size response = self.url_open('/web/image/0/200x150') image = Image.open(io.BytesIO(response.content)) self.assertEqual(image.size, (200, 150)) + # CASE: resize placeholder to small response = self.url_open('/web/image/fake/0/image_small') image = Image.open(io.BytesIO(response.content)) self.assertEqual(image.size, (64, 64)) + + # CASE: resize placeholder to medium + response = self.url_open('/web/image/fake/0/image_medium') + image = Image.open(io.BytesIO(response.content)) + self.assertEqual(image.size, (128, 128)) + + # CASE: resize placeholder to large + response = self.url_open('/web/image/fake/0/image_large') + image = Image.open(io.BytesIO(response.content)) + self.assertEqual(image.size, (256, 256)) + + # CASE: resize placeholder to big (but placeholder image is too small) + response = self.url_open('/web/image/fake/0/image') + image = Image.open(io.BytesIO(response.content)) + self.assertEqual(image.size, (256, 256)) + + # CASE: no size found, use placeholder original size + response = self.url_open('/web/image/fake/0/image_no_size') + image = Image.open(io.BytesIO(response.content)) + self.assertEqual(image.size, (256, 256)) |
