-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[17.0] [MIG] tg_event_guest #41
Conversation
…твующих пользователей
f2e6b0e
to
642f44f
Compare
class TestMain(TransactionCase): | ||
def test_signup_01(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Traceback (most recent call last):
File "/__w/tg-addons/tg-addons/tg_event_guest/tests/test_main.py", line 52, in test_signup_01
guest_user_tuple = Users.signup(
File "/__w/tg-addons/tg-addons/tg_event_guest/models/res_users.py", line 24, in signup
guest_register_code = request.params.get("guest_register_code")
File "/opt/odoo-venv/lib/python3.10/site-packages/werkzeug/local.py", line 432, in __get__
obj = instance._get_current_object()
File "/opt/odoo-venv/lib/python3.10/site-packages/werkzeug/local.py", line 554, in _get_current_object
return self.__local() # type: ignore
File "/opt/odoo-venv/lib/python3.10/site-packages/werkzeug/local.py", line 226, in _lookup
raise RuntimeError("object unbound")
RuntimeError: object unbound
Это исправляется вводом patch_request
tg-addons/website_sale_affiliate/tests/test_sale_affiliate_request.py
Lines 14 to 19 in b4ead4b
def patch_request(func): | |
def _decorator(self, *args, **kwargs): | |
with MockRequest(self.env) as req: | |
return func(self, req, *args, **kwargs) | |
return _decorator |
и примением его к методу с тестом
tg-addons/website_sale_affiliate/tests/test_sale_affiliate_request.py
Lines 44 to 46 in b4ead4b
@patch_request | |
def test_defaults_all_present(self, request_mock): |
tg_event_guest/models/res_users.py
Outdated
guest_register_code = values.pop("guest_register_code", False) | ||
res = super().signup(values, token) | ||
guest_register_code = request.params.get("guest_register_code") | ||
if guest_register_code: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff --git a/tg_event_guest/controllers/main.py b/tg_event_guest/controllers/main.py
index 1fc6d77..5173aa7 100644
--- a/tg_event_guest/controllers/main.py
+++ b/tg_event_guest/controllers/main.py
@@ -26,3 +26,9 @@ class AuthSignupHome(BaseAuthSignupHome):
qcontext["error"] = _("You need to logout to register guest")
return qcontext
+
+ def _prepare_signup_values(self, qcontext):
+ values = super()._prepare_signup_values(qcontext)
+ if qcontext.get("guest_register_code"):
+ values["guest_register_code"] = qcontext["guest_register_code"]
+ return values
diff --git a/tg_event_guest/models/res_users.py b/tg_event_guest/models/res_users.py
index 6c22af0..dd3a9ac 100644
--- a/tg_event_guest/models/res_users.py
+++ b/tg_event_guest/models/res_users.py
@@ -21,7 +21,6 @@ class ResUsers(models.Model):
def signup(self, values, token=None):
guest_register_code = values.pop("guest_register_code", False)
res = super().signup(values, token)
- guest_register_code = request.params.get("guest_register_code")
if guest_register_code:
guest = self.env["event.guest"]._get_by_code(guest_register_code)
if guest and not guest.result_partner:
diff --git a/tg_event_guest/tests/test_main.py b/tg_event_guest/tests/test_main.py
index de9cf09..6c9ef8e 100644
--- a/tg_event_guest/tests/test_main.py
+++ b/tg_event_guest/tests/test_main.py
@@ -58,8 +58,6 @@ class TestMain(TransactionCase):
}
)
guest_user = Users.search([("login", "=", guest_user_tuple[1])])
-
- guest._invalidate_cache(fnames=["result_partner"])
+ guest = self.env["event.guest"].browse(guest.id)
self.assertEqual(guest.result_partner, guest_user.partner_id)
# for example, some reason other test user registered with already used guest code # noqa: E501
tg_event_guest/tests/test_main.py
Outdated
|
||
guest._invalidate_cache(fnames=["result_partner"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да пожалуй. Не могу найти причину, почему этот invalidate_cache сбрасывает значение, когда модуль ведет себя корректно.
Можно переделать, как я описал тут https://github.com/it-projects-llc/tg-addons/pull/41/files#r1843477360
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
То есть заменить invalidate_cache на guest = self.env["event.guest"].browse(guest.id)?
f717f8d
to
9948e5e
Compare
9948e5e
to
cd7e767
Compare
[17.0] [MIG] tg_event_guest