[REF] all: pass pre-commit on the whole repo
Some checks failed
CI / lint (pull_request) Successful in 33s
CI / test (pull_request) Failing after 9m29s
CI / review (pull_request) Has been skipped

Needed for the lint job of the CI to go green. Mostly automatic hook
fixes (black, isort, prettier, pyupgrade, autoflake, whitespace). By hand:

- flake8: two unused imports, an ambiguous variable name `l`.
- pylint-odoo mandatory: manifest keys equal to their default value
  (installable, application, data, external_dependencies).
- end-of-file-fixer skips *.patch too, like trailing-whitespace: the
  upstream patches stay as git format-patch wrote them.

No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GitHub Copilot 2026-10-04 14:17:09 +02:00
parent d9d9e8be2d
commit fbd43bb459
Signed by: snt
GPG key ID: A9FD34930EADBE71
45 changed files with 330 additions and 295 deletions

View file

@ -7,8 +7,8 @@ import time
from urllib.parse import unquote
from odoo.fields import Date
from odoo.tests import HttpCase, tagged
from odoo.tests import HttpCase
from odoo.tests import tagged
@tagged("post_install", "-at_install")
@ -21,28 +21,34 @@ class TestMembershipSignupTour(HttpCase):
cls.website.auth_signup_uninvited = "b2b"
cls.website.membership_signup_required = True
today = Date.to_date(Date.today())
cls.membership_product = cls.env["product.template"].create({
"name": "Membership Test Product",
"membership": True,
"list_price": 60.0,
"is_published": True,
"sale_ok": True,
"website_id": cls.website.id,
"membership_date_from": today.replace(month=1, day=1),
"membership_date_to": today.replace(month=12, day=31),
})
cls.regular_product = cls.env["product.template"].create({
"name": "Regular Test Product",
"membership": False,
"list_price": 5.0,
"is_published": True,
"sale_ok": True,
"website_id": cls.website.id,
})
cls.membership_product = cls.env["product.template"].create(
{
"name": "Membership Test Product",
"membership": True,
"list_price": 60.0,
"is_published": True,
"sale_ok": True,
"website_id": cls.website.id,
"membership_date_from": today.replace(month=1, day=1),
"membership_date_to": today.replace(month=12, day=31),
}
)
cls.regular_product = cls.env["product.template"].create(
{
"name": "Regular Test Product",
"membership": False,
"list_price": 5.0,
"is_published": True,
"sale_ok": True,
"website_id": cls.website.id,
}
)
# Enable the custom/transfer payment provider if it is installed so the
# cart page renders fully (no checkout/payment is exercised by the
# tours, but it avoids warnings during cart rendering).
provider = cls.env.ref("payment.payment_provider_transfer", raise_if_not_found=False)
provider = cls.env.ref(
"payment.payment_provider_transfer", raise_if_not_found=False
)
if provider and provider.state != "enabled":
provider.write({"state": "enabled", "is_published": True})
@ -54,20 +60,24 @@ class TestMembershipSignupTour(HttpCase):
)
# The tour submitted the signup form, so a new portal user must exist
# and the cart of that user must contain the membership product.
users = self.env["res.users"].search([
("login", "like", "membership.tour.%@test.example.com"),
])
users = self.env["res.users"].search(
[
("login", "like", "membership.tour.%@test.example.com"),
]
)
self.assertTrue(users, "Tour should have created a user via /web/signup")
first = users.sorted("create_date")[-1]
self.assertTrue(first.partner_id.firstname)
self.assertTrue(first.partner_id.lastname)
carts = self.env["sale.order"].search([
("partner_id", "=", first.partner_id.id),
("state", "=", "draft"),
])
carts = self.env["sale.order"].search(
[
("partner_id", "=", first.partner_id.id),
("state", "=", "draft"),
]
)
self.assertTrue(carts)
order_lines = carts.mapped("order_line").filtered(
lambda l: l.product_id.product_tmpl_id == self.membership_product
lambda line: line.product_id.product_tmpl_id == self.membership_product
)
self.assertTrue(order_lines, "Cart must contain the membership product")
@ -93,7 +103,7 @@ class TestMembershipSignupTour(HttpCase):
return None
secret = self.env["ir.config_parameter"].sudo().get_param("database.secret")
max_ts = int(time.time() + 31536000) # 1y, matches Odoo's default.
msg = f"{sid}{max_ts}".encode("utf-8")
msg = f"{sid}{max_ts}".encode()
hm = hmac.new(secret.encode("ascii"), msg, hashlib.sha1).hexdigest()
return f"{hm}o{max_ts}"
@ -106,8 +116,10 @@ class TestMembershipSignupTour(HttpCase):
product_url = "/shop/%s" % self.env["ir.http"]._slug(product)
page = self.url_open(product_url, allow_redirects=True)
self.assertEqual(
page.status_code, 200,
"Product page must render (got %s for %s)" % (page.status_code, product_url),
page.status_code,
200,
"Product page must render (got %s for %s)"
% (page.status_code, product_url),
)
match = self._CSRF_RE.search(page.text)
csrf_token = match.group(1) if match else self._compute_csrf_token()
@ -199,4 +211,4 @@ class TestMembershipSignupTour(HttpCase):
self.assertIn("/shop/cart", location)
self.assertNotIn("/web/signup", location)
finally:
self.website.membership_signup_required = True
self.website.membership_signup_required = True