From 8846ad9545388e9c2e71fd8f5f948b8a450ccf9d Mon Sep 17 00:00:00 2001 From: Florian Charlier Date: Tue, 26 Mar 2024 13:00:55 +0100 Subject: [PATCH] [FIX] survey: fix test_survey_invite_action for session_code In c983f8a5 we updated the `test_survey_invite_action` test to create surveys in batch instead of one by one. This is problematic because `session_code` (given by utility method) must be unique for all surveys. Technically, using 6-digit codes makes it very unlikely that a collision occurs with existing records (see Survey._get_default_session_code's iterative process). Task-3829536 closes odoo/odoo#159295 Signed-off-by: Julien Castiaux (juc) --- addons/survey/tests/test_survey_invite.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/survey/tests/test_survey_invite.py b/addons/survey/tests/test_survey_invite.py index 768184a50aa..f00f73f13ef 100644 --- a/addons/survey/tests/test_survey_invite.py +++ b/addons/survey/tests/test_survey_invite.py @@ -40,11 +40,13 @@ class TestSurveyInvite(common.TestSurveyCommon, MailCommon): bad_cases = [ {}, # empty { # no question - 'question_and_page_ids': [Command.create({'is_page': True, 'question_type': False, 'title': 'P0', 'sequence': 1})] + 'question_and_page_ids': [Command.create({'is_page': True, 'question_type': False, 'title': 'P0', 'sequence': 1})], + 'session_code': '100000', }, { # scored without positive score obtainable 'scoring_type': 'scoring_with_answers', 'question_and_page_ids': [Command.create({'question_type': 'numerical_box', 'title': 'Q0', 'sequence': 1})], + 'session_code': '100001', }, { # scored without positive score obtainable from simple choice 'scoring_type': 'scoring_with_answers', @@ -56,13 +58,15 @@ class TestSurveyInvite(common.TestSurveyCommon, MailCommon): Command.create({'value': '2', 'answer_score': 0}), ], })], + 'session_code': '100002', }, { # closed 'active': False, 'question_and_page_ids': [ Command.create({'is_page': True, 'question_type': False, 'title': 'P0', 'sequence': 1}), Command.create({'title': 'Q0', 'sequence': 2, 'question_type': 'text_box'}) - ] + ], + 'session_code': '100003', }, ] good_cases = [ @@ -72,6 +76,7 @@ class TestSurveyInvite(common.TestSurveyCommon, MailCommon): 'question_and_page_ids': [ Command.create({'question_type': 'numerical_box', 'title': 'Q0', 'sequence': 1, 'answer_score': 1}), ], + 'session_code': '100004', }, { # scored with positive score obtainable from simple choice 'scoring_type': 'scoring_with_answers', @@ -91,7 +96,9 @@ class TestSurveyInvite(common.TestSurveyCommon, MailCommon): Command.create({'value': '1', 'answer_score': 0}), Command.create({'value': '2', 'answer_score': 1}), ], - })], + }), + ], + 'session_code': '100005', }, ] surveys = self.env['survey.survey'].with_user(self.survey_manager).create([