mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-27 15:17:44 -06:00
[MIG] attachment_preview: Migration to 18.0
Increased code coverage Changed layout of attachment_preview buttons
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
|
||||
import base64
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.addons.base.tests.common import BaseCommon
|
||||
|
||||
|
||||
class TestAttachmentPreview(TransactionCase):
|
||||
class TestAttachmentPreview(BaseCommon):
|
||||
def test_get_extension(self):
|
||||
attachment = self.env["ir.attachment"].create(
|
||||
{
|
||||
@@ -20,6 +20,12 @@ class TestAttachmentPreview(TransactionCase):
|
||||
"name": "image.png",
|
||||
}
|
||||
)
|
||||
attachment3 = self.env["ir.attachment"].create(
|
||||
{
|
||||
"datas": base64.b64encode(b"Png"),
|
||||
"name": "image",
|
||||
}
|
||||
)
|
||||
res = self.env["ir.attachment"].get_attachment_extension(attachment.id)
|
||||
self.assertEqual(res, "txt")
|
||||
|
||||
@@ -41,3 +47,18 @@ class TestAttachmentPreview(TransactionCase):
|
||||
"ir.module.module", module.id, "icon_image"
|
||||
)
|
||||
self.assertTrue(res3)
|
||||
|
||||
res4 = self.env["ir.attachment"].get_binary_extension(
|
||||
"ir.attachment", attachment3.id, "datas", "name"
|
||||
)
|
||||
self.assertTrue(res4)
|
||||
|
||||
res5 = self.env["ir.attachment"].get_binary_extension(
|
||||
"ir.attachment", attachment.id, None
|
||||
)
|
||||
self.assertFalse(res5)
|
||||
|
||||
res6 = self.env["ir.attachment"].get_binary_extension(
|
||||
"ir.attachment", attachment3.id, "datas", "dummy"
|
||||
)
|
||||
self.assertTrue(res6)
|
||||
|
||||
Reference in New Issue
Block a user