[ADD] ci: CI de Forgejo, bots y pre-commit en todo el repo #19
1 changed files with 20 additions and 14 deletions
|
|
@ -23,7 +23,6 @@ from datetime import timedelta
|
|||
from types import SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
from odoo.addons.website_sale_aplicoop.controllers.website_sale import (
|
||||
|
|
@ -34,6 +33,16 @@ REQUEST_PATCH_TARGET = (
|
|||
"odoo.addons.website_sale_aplicoop.controllers.website_sale.request"
|
||||
)
|
||||
|
||||
# Languages the tests put in the request env. A fresh database (the CI's) only
|
||||
# has en_US active, and `env.lang` raises "Invalid language code" for the rest.
|
||||
TEST_LANGS = ("es_ES", "eu_ES", "ca_ES", "gl_ES", "pt_PT", "fr_FR", "it_IT")
|
||||
|
||||
|
||||
def _activate_test_langs(env):
|
||||
"""Activate TEST_LANGS: no translations are loaded, only the codes."""
|
||||
for lang in TEST_LANGS:
|
||||
env["res.lang"]._activate_lang(lang)
|
||||
|
||||
|
||||
def _env_with_lang(env, lang):
|
||||
"""Return a cloned environment with language context set."""
|
||||
|
|
@ -59,9 +68,8 @@ def _build_request_mock(env, payload=None, website=None):
|
|||
"""
|
||||
if website is None:
|
||||
# `pricelist_id` is what the pricing helpers read now that Eskaera
|
||||
# prices with the standard website pricelist. Ordered by id on
|
||||
# purpose: the multilang cases build an env whose language is not
|
||||
# installed, and the default order is by the translated `name`.
|
||||
# prices with the standard website pricelist. Ordered by id so the
|
||||
# pick does not depend on the translated `name` of each language.
|
||||
website = SimpleNamespace(
|
||||
pricelist_id=env["product.pricelist"]
|
||||
.sudo()
|
||||
|
|
@ -364,6 +372,7 @@ class TestProcessCartItems(TransactionCase):
|
|||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
_activate_test_langs(self.env)
|
||||
self.controller = AplicoopWebsiteSale()
|
||||
|
||||
# Create test products
|
||||
|
|
@ -525,6 +534,7 @@ class TestBuildConfirmationMessage(TransactionCase):
|
|||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
_activate_test_langs(self.env)
|
||||
self.controller = AplicoopWebsiteSale()
|
||||
self.user = self.env.ref("base.user_admin")
|
||||
self.partner = self.env.ref("base.partner_admin")
|
||||
|
|
@ -562,16 +572,11 @@ class TestBuildConfirmationMessage(TransactionCase):
|
|||
):
|
||||
request_mock = _build_request_mock(_env_with_lang(self.env, lang))
|
||||
with patch(REQUEST_PATCH_TARGET, request_mock):
|
||||
try:
|
||||
return self.controller._build_confirmation_message(
|
||||
sale_order or self.sale_order,
|
||||
group_order or self.group_order,
|
||||
is_delivery=is_delivery,
|
||||
)
|
||||
except UserError as err:
|
||||
if "Invalid language code" in str(err):
|
||||
self.skipTest(str(err))
|
||||
raise
|
||||
return self.controller._build_confirmation_message(
|
||||
sale_order or self.sale_order,
|
||||
group_order or self.group_order,
|
||||
is_delivery=is_delivery,
|
||||
)
|
||||
|
||||
def test_build_confirmation_message_pickup(self):
|
||||
"""Test confirmation message for pickup (not delivery)."""
|
||||
|
|
@ -669,6 +674,7 @@ class TestConfirmEskaera_Integration(TransactionCase):
|
|||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
_activate_test_langs(self.env)
|
||||
self.controller = AplicoopWebsiteSale()
|
||||
self.consumer_group = self.env["res.partner"].create(
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue