diff options
| author | Debauche Stéphane <std@odoo.com> | 2020-02-04 08:06:28 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-02-18 15:59:12 +0000 |
| commit | 3721f49d4e64f29eb07686787bef77797fc69bc8 (patch) | |
| tree | e71a471e49b9a8f7fb62006a84a133cf697e9754 /addons/website_event_questions/tests | |
| parent | 9b55dfcc35f660fe94e376d14e63d30c33c068b1 (diff) | |
[FIX] website_event(_questions): correctly parse frontend question answers
When user register to an event from website, they can answer questions
specific to a given registration or to all registrations. However they
are not correctly parsed and not saved.
Task 2188857
PR #44545
X-original-commit: e27d9b5c4f234f6ce64456c2f52e7cfb0331332f
Diffstat (limited to 'addons/website_event_questions/tests')
| -rw-r--r-- | addons/website_event_questions/tests/test_event_internals.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/addons/website_event_questions/tests/test_event_internals.py b/addons/website_event_questions/tests/test_event_internals.py index dd13343b62c..aedaf148fc9 100644 --- a/addons/website_event_questions/tests/test_event_internals.py +++ b/addons/website_event_questions/tests/test_event_internals.py @@ -3,9 +3,11 @@ from datetime import datetime, timedelta -from odoo.addons.website_event_questions.tests.common import TestEventQuestionCommon from odoo.fields import Datetime as FieldsDatetime from odoo.tests.common import users +from odoo.addons.website.tools import MockRequest +from odoo.addons.website_event_questions.controllers.main import WebsiteEvent +from odoo.addons.website_event_questions.tests.common import TestEventQuestionCommon class TestEventData(TestEventQuestionCommon): @@ -29,3 +31,34 @@ class TestEventData(TestEventQuestionCommon): self.assertEqual( set(event.general_question_ids.mapped('answer_ids.name')), set(['Q2-Answer1', 'Q2-Answer2'])) + + def test_process_attendees_form(self): + event = self.env['event.event'].create({ + 'name': 'Event Update Type', + 'event_type_id': self.event_type_complex.with_user(self.env.user).id, + 'date_begin': FieldsDatetime.to_string(datetime.today() + timedelta(days=1)), + 'date_end': FieldsDatetime.to_string(datetime.today() + timedelta(days=15)), + }) + + form_details = { + '1-name': 'Pixis', + '1-email': 'pixis@gmail.com', + '1-phone': '+32444444444', + '1-event_ticket_id': '2', + '1-answer_ids-8': '5', + '2-name': 'Geluchat', + '2-email': 'geluchat@gmail.com', + '2-phone': '+32777777777', + '2-event_ticket_id': '3', + '2-answer_ids-8': '9', + '0-answer_ids-3': '7', + '0-answer_ids-4': '1', + } + + with MockRequest(self.env): + registrations = WebsiteEvent()._process_attendees_form(event, form_details) + + self.assertEqual(registrations, [ + {'name': 'Pixis', 'email': 'pixis@gmail.com', 'phone': '+32444444444', 'event_ticket_id': 2, 'answer_ids': [[4, 5], [4, 7], [4, 1]]}, + {'name': 'Geluchat', 'email': 'geluchat@gmail.com', 'phone': '+32777777777', 'event_ticket_id': 3, 'answer_ids': [[4, 9], [4, 7], [4, 1]]} + ]) |
