Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Converter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo modules
Converter
Commits
56e7566b
Commit
56e7566b
authored
1 month ago
by
Axel Prel
Browse files
Options
Downloads
Patches
Plain Diff
qr-code test
parent
44395259
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/__init__.py
+1
-0
1 addition, 0 deletions
tests/__init__.py
tests/test_qr_code.py
+62
-0
62 additions, 0 deletions
tests/test_qr_code.py
with
63 additions
and
0 deletions
tests/__init__.py
+
1
−
0
View file @
56e7566b
...
...
@@ -4,6 +4,7 @@
test_field
,
test_ir_model
,
test_mail_template
,
test_qr_code
,
test_relation
,
test_switch
,
test_validate
,
...
...
This diff is collapsed.
Click to expand it.
tests/test_qr_code.py
0 → 100644
+
62
−
0
View file @
56e7566b
##############################################################################
#
# Converter Odoo module
# Copyright © 2025 XCG Consulting <https://xcg-consulting.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from
unittest
import
skipUnless
from
odoo
import
tests
# type: ignore[import-untyped]
from
..
import
QRCodeDataURL
,
QRCodeFile
,
stringToQRCode
@skipUnless
(
tests
.
can_import
(
"
qrcode
"
),
"
qrcode module not available
"
)
class
TestQRCode
(
tests
.
TransactionCase
):
def
setUp
(
self
):
super
().
setUp
()
self
.
ready_mat
=
self
.
env
[
"
res.partner
"
].
search
(
[(
"
name
"
,
"
=
"
,
"
Ready Mat
"
)],
limit
=
1
)
def
test_print_qr_code_1
(
self
):
qr
=
stringToQRCode
(
"
https://google.com
"
)
qr
.
print_ascii
()
def
test_string_to_qr_code_2
(
self
):
qr
=
stringToQRCode
(
self
.
ready_mat
.
website
)
qr
.
print_ascii
()
def
test_qr_code_file
(
self
):
converter
=
QRCodeFile
(
"
website
"
)
img
=
converter
.
odoo_to_message
(
self
.
ready_mat
)
self
.
assertEqual
(
"
image/png
"
,
img
[
"
mime-type
"
])
self
.
assertRegex
(
img
[
"
body
"
],
r
"
[A-Za-z0-9+/=]+$
"
,
"
The generated base64 body is incorrect
"
,
)
def
test_qr_code_data_url
(
self
):
converter
=
QRCodeDataURL
(
"
website
"
)
url
=
converter
.
odoo_to_message
(
self
.
ready_mat
)
self
.
assertRegex
(
url
,
r
"
^data:image/png;base64,[A-Za-z0-9+/=]+$
"
,
"
The generated Data URL is not correctly formatted
"
,
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment