diff options
| author | Thibault Delavallée <tde@odoo.com> | 2019-11-25 12:26:57 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-12-05 15:21:28 +0000 |
| commit | 2592e72f2cd80f09fb23b4b16f8eb92ba253ff67 (patch) | |
| tree | ed6af2529339fc37003f28384aab8499bde85aa0 /addons/survey/tests | |
| parent | 84bb9c748db26656d3ecd062183afe5f042dc569 (diff) | |
[REF] survey: globally rename survey.label model to survey.question.answer
PURPOSE
As new features are about to land in survey, notably live interactions [1]
and new survey building [2] performing a pre cleaning is necessary. In this
PR we clean survey models by: removing unnecessary fields, cleaning some code
and finally renaming models.
SPECIFICATIONS
In this commit we rename the long standing ``survey.label`` model. Indeed
a label is something before a question, like an input label. Labels in survey
are used for suggested answers and sometimes as rows for matrix answers.
After much thoughts we rename ``survey.label`` to ``survey.question.answer``.
It indicates this model holds answers. Moreover it is namespaced within the
``survey.question`` model name to avoid conflict with user input / user answer
model.
As model naming changes, some fields also evolve. In survey.question model
* ``labels_id`` is renamed to ``suggested_answer_ids`` to indicate it is
used to display suggested values to the user;
* ``labels_id_2`` is renamed to ``matrix_row_ids`` to indicate it is used
to generate the rows of the matrix-type question. A matrix is therefore
done using ``matrix_row_ids`` for rows and ``suggested_answer_ids`` for
columns which seems easier to understand;
In survey.question.answer (old survey.label) model
* ``question_id_2`` is renamed to ``matrix_question_id`` to ease its
understanding, notably that it is used for matrix questions;
LINKS
[0] Related to Task ID 2061901 (survey models cleaning and preparation)
[1] Task ID 1972640 (live interactions)
[2] Task ID 2119587 (new frontend for building surveys)
PR #40765
Diffstat (limited to 'addons/survey/tests')
| -rw-r--r-- | addons/survey/tests/common.py | 6 | ||||
| -rw-r--r-- | addons/survey/tests/test_certification_flow.py | 10 | ||||
| -rw-r--r-- | addons/survey/tests/test_survey.py | 10 | ||||
| -rw-r--r-- | addons/survey/tests/test_survey_flow.py | 2 | ||||
| -rw-r--r-- | addons/survey/tests/test_survey_ui_certification.py | 14 | ||||
| -rw-r--r-- | addons/survey/tests/test_survey_ui_feedback.py | 8 |
6 files changed, 25 insertions, 25 deletions
diff --git a/addons/survey/tests/common.py b/addons/survey/tests/common.py index 9d000da6f13..74a74dc463c 100644 --- a/addons/survey/tests/common.py +++ b/addons/survey/tests/common.py @@ -163,7 +163,7 @@ class TestSurveyCommon(common.SavepointCase): 'constr_error_msg': constr_error_msg, } if qtype in ('simple_choice', 'multiple_choice'): - base_qvalues['labels_ids'] = [ + base_qvalues['suggested_answer_ids'] = [ (0, 0, { 'value': label['value'], 'answer_score': label.get('answer_score', 0), @@ -172,11 +172,11 @@ class TestSurveyCommon(common.SavepointCase): ] elif qtype == 'matrix': base_qvalues['matrix_subtype'] = kwargs.pop('matrix_subtype', 'simple') - base_qvalues['labels_ids'] = [ + base_qvalues['suggested_answer_ids'] = [ (0, 0, {'value': label['value'], 'answer_score': label.get('answer_score', 0)}) for label in kwargs.pop('labels') ] - base_qvalues['labels_ids_2'] = [ + base_qvalues['matrix_row_ids'] = [ (0, 0, {'value': label['value'], 'answer_score': label.get('answer_score', 0)}) for label in kwargs.pop('labels_2') ] diff --git a/addons/survey/tests/test_certification_flow.py b/addons/survey/tests/test_certification_flow.py index 4625fff5d5e..4df1245d2c2 100644 --- a/addons/survey/tests/test_certification_flow.py +++ b/addons/survey/tests/test_certification_flow.py @@ -116,13 +116,13 @@ class TestCertificationFlow(common.TestSurveyCommon, HttpCase): csrf_token = self._find_csrf_token(response.text) with patch.object(IrMailServer, 'connect'): - self._answer_question(q01, q01.labels_ids.ids[3], answer_token, csrf_token) - self._answer_question(q02, q02.labels_ids.ids[1], answer_token, csrf_token) + self._answer_question(q01, q01.suggested_answer_ids.ids[3], answer_token, csrf_token) + self._answer_question(q02, q02.suggested_answer_ids.ids[1], answer_token, csrf_token) self._answer_question(q03, "I think they're great!", answer_token, csrf_token) - self._answer_question(q04, q04.labels_ids.ids[0], answer_token, csrf_token, button_submit='previous') + self._answer_question(q04, q04.suggested_answer_ids.ids[0], answer_token, csrf_token, button_submit='previous') self._answer_question(q03, "Just kidding, I don't like it...", answer_token, csrf_token) - self._answer_question(q04, q04.labels_ids.ids[0], answer_token, csrf_token) - self._answer_question(q05, [q05.labels_ids.ids[0], q05.labels_ids.ids[1], q05.labels_ids.ids[3]], answer_token, csrf_token) + self._answer_question(q04, q04.suggested_answer_ids.ids[0], answer_token, csrf_token) + self._answer_question(q05, [q05.suggested_answer_ids.ids[0], q05.suggested_answer_ids.ids[1], q05.suggested_answer_ids.ids[3]], answer_token, csrf_token) user_inputs.invalidate_cache() # Check that certification is successfully passed diff --git a/addons/survey/tests/test_survey.py b/addons/survey/tests/test_survey.py index 6c64d47f763..fc79ae5c053 100644 --- a/addons/survey/tests/test_survey.py +++ b/addons/survey/tests/test_survey.py @@ -130,10 +130,10 @@ class TestSurveyInternals(common.TestSurveyCommon): for i in range(3): answer = self._add_answer(self.survey, False, email='public@example.com') self._add_answer_line( - question, answer, random.choice(question.labels_ids.ids), + question, answer, random.choice(question.suggested_answer_ids.ids), answer_type='suggestion', answer_fname='value_suggested') lines = [line.value_suggested.id for line in question.user_input_line_ids] - answers = [{'text': label.value, 'count': lines.count(label.id), 'answer_id': label.id, 'answer_score': label.answer_score} for label in question.labels_ids] + answers = [{'text': label.value, 'count': lines.count(label.id), 'answer_id': label.id, 'answer_score': label.answer_score} for label in question.suggested_answer_ids] prp_result = self.env['survey.survey'].prepare_result(question)['answers'] self.assertItemsEqual(prp_result, answers) @@ -147,12 +147,12 @@ class TestSurveyInternals(common.TestSurveyCommon): for i in range(3): answer = self._add_answer(self.survey, False, email='public@example.com') self._add_answer_line( - question, answer, random.choice(question.labels_ids.ids), - answer_type='suggestion', answer_fname='value_suggested', value_suggested_row=random.choice(question.labels_ids_2.ids) + question, answer, random.choice(question.suggested_answer_ids.ids), + answer_type='suggestion', answer_fname='value_suggested', value_suggested_row=random.choice(question.matrix_row_ids.ids) ) lines = [(line.value_suggested_row.id, line.value_suggested.id) for line in question.user_input_line_ids] res = {} - for i in product(question.labels_ids_2.ids, question.labels_ids.ids): + for i in product(question.matrix_row_ids.ids, question.suggested_answer_ids.ids): res[i] = lines.count((i)) self.assertEqual(self.env['survey.survey'].prepare_result(question)['result'], res) diff --git a/addons/survey/tests/test_survey_flow.py b/addons/survey/tests/test_survey_flow.py index 472eaff55fd..5f45d2856fd 100644 --- a/addons/survey/tests/test_survey_flow.py +++ b/addons/survey/tests/test_survey_flow.py @@ -106,7 +106,7 @@ class TestSurveyFlow(common.TestSurveyCommon, HttpCase): # Customer submit second page answers answer_data = { - page1_q0.id: {'value': [page1_q0.labels_ids.ids[0], page1_q0.labels_ids.ids[1]]}, + page1_q0.id: {'value': [page1_q0.suggested_answer_ids.ids[0], page1_q0.suggested_answer_ids.ids[1]]}, } post_data = self._format_submission_data(page_1, answer_data, {'csrf_token': csrf_token, 'token': answer_token, 'button_submit': 'next'}) r = self._access_submit(survey, answer_token, post_data) diff --git a/addons/survey/tests/test_survey_ui_certification.py b/addons/survey/tests/test_survey_ui_certification.py index f5a6e5645c4..a98f8966e55 100644 --- a/addons/survey/tests/test_survey_ui_certification.py +++ b/addons/survey/tests/test_survey_ui_certification.py @@ -38,7 +38,7 @@ class TestUiCertification(HttpCaseWithUserDemo): 'question_type': 'simple_choice', 'display_mode': 'dropdown', 'constr_mandatory': True, - 'labels_ids': [ + 'suggested_answer_ids': [ (0, 0, { 'value': 'No', 'sequence': 1, @@ -54,7 +54,7 @@ class TestUiCertification(HttpCaseWithUserDemo): 'sequence': 3, 'question_type': 'multiple_choice', 'column_nb': '4', - 'labels_ids': [ + 'suggested_answer_ids': [ (0, 0, { 'value': 'Chair floor protection', 'sequence': 1, @@ -85,7 +85,7 @@ class TestUiCertification(HttpCaseWithUserDemo): 'sequence': 4, 'question_type': 'multiple_choice', 'column_nb': '4', - 'labels_ids': [ + 'suggested_answer_ids': [ (0, 0, { 'value': 'Color', 'sequence': 1, @@ -117,7 +117,7 @@ class TestUiCertification(HttpCaseWithUserDemo): 'question_type': 'simple_choice', 'display_mode': 'dropdown', 'constr_mandatory': True, - 'labels_ids': [ + 'suggested_answer_ids': [ (0, 0, { 'value': 1, 'sequence': 1, @@ -150,7 +150,7 @@ class TestUiCertification(HttpCaseWithUserDemo): 'question_type': 'simple_choice', 'display_mode': 'dropdown', 'constr_mandatory': True, - 'labels_ids': [ + 'suggested_answer_ids': [ (0, 0, { 'value': '20$', 'sequence': 1, @@ -178,7 +178,7 @@ class TestUiCertification(HttpCaseWithUserDemo): 'sequence': 9, 'question_type': 'multiple_choice', 'column_nb': '2', - 'labels_ids': [ + 'suggested_answer_ids': [ (0, 0, { 'value': 'Corner Desk Right Sit', 'sequence': 1, @@ -214,7 +214,7 @@ class TestUiCertification(HttpCaseWithUserDemo): 'question_type': 'simple_choice', 'display_mode': 'dropdown', 'constr_mandatory': True, - 'labels_ids': [ + 'suggested_answer_ids': [ (0, 0, { 'value': 'Very underpriced', 'sequence': 1, diff --git a/addons/survey/tests/test_survey_ui_feedback.py b/addons/survey/tests/test_survey_ui_feedback.py index 2e10d757f8e..2447f7916dc 100644 --- a/addons/survey/tests/test_survey_ui_feedback.py +++ b/addons/survey/tests/test_survey_ui_feedback.py @@ -43,7 +43,7 @@ class TestUiFeedback(HttpCaseWithUserDemo): 'comments_allowed': True, 'comment_count_as_answer': True, 'constr_mandatory': True, - 'labels_ids': [ + 'suggested_answer_ids': [ (0, 0, { 'value': 'Once a day', 'sequence': 1, @@ -78,7 +78,7 @@ class TestUiFeedback(HttpCaseWithUserDemo): 'constr_mandatory': True, 'comments_allowed': True, 'comment_count_as_answer': False, - 'labels_ids': [ + 'suggested_answer_ids': [ (0, 0, { 'value': 'High quality', 'sequence': 1, @@ -113,7 +113,7 @@ class TestUiFeedback(HttpCaseWithUserDemo): 'question_type': 'matrix', 'matrix_subtype': 'multiple', 'constr_mandatory': True, - 'labels_ids': [(0, 0, { + 'suggested_answer_ids': [(0, 0, { 'value': 'Totally disagree', 'sequence': 1 }), (0, 0, { @@ -126,7 +126,7 @@ class TestUiFeedback(HttpCaseWithUserDemo): 'value': 'Totally agree', 'sequence': 4, })], - 'labels_ids_2': [(0, 0, { + 'matrix_row_ids': [(0, 0, { 'value': 'The new layout and design is fresh and up-to-date', 'sequence': 1, }), (0, 0, { |
