Skip to content

Commit

Permalink
[MIG] base_user_signature: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Jan 29, 2025
1 parent 5d37bcb commit a8e6ef1
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 1 deletion.
3 changes: 3 additions & 0 deletions base_user_signature/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------
Expand Down
2 changes: 1 addition & 1 deletion base_user_signature/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{
"name": "Base User Signature",
"version": "16.0.1.0.0",
"version": "18.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"license": "AGPL-3",
Expand Down
2 changes: 2 additions & 0 deletions base_user_signature/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions base_user_signature/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Maxime Chambreuil &lt;<a class="reference external" href="mailto:mchambreuil&#64;opensourceintegrators.com">mchambreuil&#64;opensourceintegrators.com</a>&gt;</li>
<li>Italo LOPES &lt;<a class="reference external" href="mailto:contact&#64;ilopes.me">contact&#64;ilopes.me</a>&gt;</li>
<li>Saran Lim. &lt;<a class="reference external" href="mailto:saranl&#64;ecosoft.co.th">saranl&#64;ecosoft.co.th</a>&gt;</li>
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a><ul>
<li>Bhavesh Heliconia</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
1 change: 1 addition & 0 deletions base_user_signature/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_base_user_signature
65 changes: 65 additions & 0 deletions base_user_signature/tests/test_base_user_signature.py
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.",
)

0 comments on commit a8e6ef1

Please sign in to comment.