-
-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] base_user_signature: Migration to 18.0
- Loading branch information
1 parent
7d0797a
commit 56011b4
Showing
6 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,9 @@ Contributors | |
- Maxime Chambreuil <[email protected]> | ||
- Italo LOPES <[email protected]> | ||
- Saran Lim. <[email protected]> | ||
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__ | ||
|
||
- Bhavesh Heliconia | ||
|
||
Maintainers | ||
----------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ | |
- Maxime Chambreuil \<<[email protected]>\> | ||
- Italo LOPES \<<[email protected]>\> | ||
- Saran Lim. \<<[email protected]>\> | ||
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) | ||
- Bhavesh Heliconia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_base_user_signature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from base64 import b64encode | ||
from io import BytesIO | ||
|
||
from PIL import Image | ||
|
||
from odoo.addons.base.tests.common import SavepointCaseWithUserDemo | ||
|
||
|
||
class TestResUsersDigitalSignature(SavepointCaseWithUserDemo): | ||
def setUp(self): | ||
super().setUp() | ||
self.user_model = self.env["res.users"] | ||
|
||
# Create a test user | ||
self.user = self.user_model.create( | ||
{ | ||
"name": "Test User", | ||
"login": "test_user", | ||
"email": "[email protected]", | ||
} | ||
) | ||
|
||
def _generate_sample_image(self): | ||
"""Generate a small valid image and return its base64-encoded content.""" | ||
img = Image.new("RGB", (10, 10), color="red") # Create a red 10x10 image | ||
buffer = BytesIO() | ||
img.save(buffer, format="PNG") | ||
return b64encode(buffer.getvalue()).decode("ascii") | ||
|
||
def test_digital_signature_field(self): | ||
"""Test assigning and clearing the digital signature field.""" | ||
# Generate a valid base64-encoded image | ||
test_signature = self._generate_sample_image() | ||
|
||
# Assign a digital signature to the user | ||
self.user.digital_signature = test_signature | ||
self.assertEqual( | ||
self.user.digital_signature.decode("ascii"), | ||
test_signature, | ||
"Digital signature should be set correctly.", | ||
) | ||
|
||
# Clear the digital signature using the method | ||
self.user.clear_digital_signature() | ||
self.assertFalse( | ||
self.user.digital_signature, "Digital signature should be cleared." | ||
) | ||
|
||
def test_self_readable_fields(self): | ||
"""Test if 'digital_signature' is included in SELF_READABLE_FIELDS.""" | ||
readable_fields = self.user.SELF_READABLE_FIELDS | ||
self.assertIn( | ||
"digital_signature", | ||
readable_fields, | ||
"'digital_signature' should be in SELF_READABLE_FIELDS.", | ||
) | ||
|
||
def test_self_writeable_fields(self): | ||
"""Test if 'digital_signature' is included in SELF_WRITEABLE_FIELDS.""" | ||
writeable_fields = self.user.SELF_WRITEABLE_FIELDS | ||
self.assertIn( | ||
"digital_signature", | ||
writeable_fields, | ||
"'digital_signature' should be in SELF_WRITEABLE_FIELDS.", | ||
) |