diff --git a/addons/survey/__openerp__.py b/addons/survey/__openerp__.py index f522ff5a36f..6c64cd4dcdd 100644 --- a/addons/survey/__openerp__.py +++ b/addons/survey/__openerp__.py @@ -48,7 +48,9 @@ Partners are also sent mails with user name and password for the invitation of t 'wizard/survey_send_invitation.xml'], 'demo_xml': ['survey_demo.xml'], 'test': [ - 'test/survey00.yml', + 'test/draft2open2close_survey.yml', + 'test/draft2open2close_request.yml', + 'test/surey_question_type.yml', 'test/survey_report.yml', ], 'installable': True, diff --git a/addons/survey/survey_demo.xml b/addons/survey/survey_demo.xml index 1d8eae17fb6..3bfac20d44b 100644 --- a/addons/survey/survey_demo.xml +++ b/addons/survey/survey_demo.xml @@ -6,6 +6,155 @@ + + + Initial Partner Feedback + + 20 + + open + 1 + 1 + 5 + + + + + Who are you? + + + + + + What is your company's name? + + single_textbox + 1 + 1 + + 1 + + + + What is your company's size? + + multiple_choice_only_one_ans + + 1 + + + + 1 + 1 - 10 + + + + + 1 + 11 - 50 + + + + + 1 + 51 - 100 + + + + + 1 + 101 - 250 + + + + + 1 + 251 - 500 + + + + + 1 + 501 - 1000 + + + + + 1 + > 1000 + + + + + + + + + Contracts + + + + + + 1 + Which maintenance contract do you sell to your customers? + + multiple_choice_only_one_ans + + + + + 1 + OpenERP maintenance contract + + + + + 1 + Your own contract, but you buy an OpenERP one + + + + + 1 + Your own contract without buying an OpenERP one + + + + + + 1 + When do you propose a maintenance contract to your customers? + + multiple_choice_only_one_ans + text + Why? + + True + + + + 1 + With each integration + + + + + 1 + Sometimes + + + + + 1 + Never... + + + + + + + OpenERP Partner Feedback diff --git a/addons/survey/test/draft2open2close_request.yml b/addons/survey/test/draft2open2close_request.yml new file mode 100644 index 00000000000..b3b5bf5c30d --- /dev/null +++ b/addons/survey/test/draft2open2close_request.yml @@ -0,0 +1,48 @@ +- + In order to check Survey Request of the survey "Initial Partner Feedback" I create a Survey Request for survey "Initial Partner Feedback". +- + !record {model: survey.request, id: survey_request_1}: + survey_id: survey_Initial_partner_feedback + user_id: base.user_demo + state: draft +- + I set Survey Request for the survey in waiting state. +- + !python {model: survey.request}: | + self.survey_req_waiting_answer(cr, uid, [ref("survey_request_1")], context) +- + I check that state of Survey Request for the survey is waiting or not. +- + !assert {model: survey.request, id: survey_request_1, severity: error, string: Survey Request should be in waiting state}: + - state == 'waiting_answer' +- + I cancel the Survey Request of the survey. +- + !python {model: survey.request}: | + self.survey_req_cancel(cr, uid, [ref("survey_request_1")], context) +- + I check that state of Survey Request of the survey is cancel or not. +- + !assert {model: survey.request, id: survey_request_1, severity: error, string: Survey Request should be in cancel state}: + - state == 'cancel' +- + I set Survey Request of the survey in draft state. +- + !python {model: survey.request}: | + self.survey_req_draft(cr, uid, [ref("survey_request_1")], context) +- + I check that state of Survey request of the survey is draft or not. +- + !assert {model: survey.request, id: survey_request_1, severity: error, string: Survey Request should be in draft state}: + - state == 'draft' +- + I set survey request of the survey in done state. +- + !python {model: survey.request}: | + self.survey_req_waiting_answer(cr, uid, [ref("survey_request_1")], context) + self.survey_req_done(cr, uid, [ref("survey_request_1")], context) +- + I check that state of Survey request of the survey is done or not. +- + !assert {model: survey.request, id: survey_request_1, severity: error, string: Survey Request should be in done state}: + - state == 'done' \ No newline at end of file diff --git a/addons/survey/test/draft2open2close_survey.yml b/addons/survey/test/draft2open2close_survey.yml new file mode 100644 index 00000000000..c271e677fb0 --- /dev/null +++ b/addons/survey/test/draft2open2close_survey.yml @@ -0,0 +1,111 @@ +- + In order to check the survey module in OpenERP I use the survey "Initial Partner Feedback". +- + I set the survey in Open state. +- + !python {model: survey}: | + sur = self.survey_open(cr, uid, [ref("survey_Initial_partner_feedback")], context) +- + I check state of survey is open or not. +- + !assert {model: survey, id: survey_Initial_partner_feedback, severity: error, string: Survey should be in open state}: + - state == 'open' +- + I check that the survey is reopened or not. +- + !python {model: survey}: | + self.survey_cancel(cr, uid, [ref('survey_Initial_partner_feedback')],context) + self.survey_open(cr, uid, [ref('survey_Initial_partner_feedback')],context) +- + I check that state of survey is open or not. +- + !assert {model: survey, id: survey_Initial_partner_feedback, severity: error, string: Survey should be in open state}: + - state == 'open' +- + I set the state of the survey open. +- + !python {model: survey}: | + sur = self.survey_open(cr, uid, [ref("survey_Initial_partner_feedback")], context) +- + In order to print the survey I click on Print. +- + !python {model: survey.print}: | + id = self.create(cr, uid, {'survey_ids': [(6,0,[ref('survey.survey_Initial_partner_feedback')])]}) + self.action_next(cr, uid, [id], context) +- + In order to answer the survey I click on "Answer a Survey" wizard. +- + !python {model: survey.name.wiz}: | + id = self.create(cr, uid, {'survey_id': ref("survey_Initial_partner_feedback")}) + self.action_next(cr, uid, [id], context) +- + I give the answer of the first and second page of the survey. +- + !python {model: survey.question.wiz}: | + ctx = {'active_model':'survey', 'active_id': ref('survey_Initial_partner_feedback'), 'active_ids': [ref('survey_Initial_partner_feedback')]} + self.fields_view_get(cr, uid, ref("survey.view_survey_question_message"),"form", context=ctx) + values = self.default_get(cr, uid, ['name'], ctx) + ids = self.create(cr, uid, {str(ref("survey_initial_question_company_name")) +"_single" :'Tiny' , str(ref("survey_initial_question_company_size")) + "_selection" : int(ref("survey.survey_initial_question_company_size_51")), }, context) + self.action_next(cr, uid, [ids], context) + ids = self.create(cr, uid, {str(ref("survey_initial_question_contract_customers")) + "_selection" : int(ref("survey_initial_answer_sometimes")), str(ref("survey_initial_question_sell_to_your_customers")) + "_selection" : int(ref("survey_initial_answer_maintenance_contract")), }, context) + self.action_next(cr, uid, [ids], context) +- + I print the answers of the survey. +- + !python {model: survey.browse.answer}: | + id = self.create(cr, uid, {'survey_id': ref('survey.survey_Initial_partner_feedback')}) + self.action_next(cr, uid, [id], context) +- + I edit questions of the survey as per requirement. +- + !python {model: survey.question.wiz}: | + name_wiz_obj = self.pool.get('survey.name.wiz') + id = name_wiz_obj.create(cr, uid, {'survey_id': ref("survey_Initial_partner_feedback")}) + ctx = {'active_model':'survey', 'active_id': ref('survey_Initial_partner_feedback'), 'active_ids': [ref('survey_Initial_partner_feedback')], 'question_id': ref('survey_initial_question_company_name'), 'page_number': -1,'sur_name_id': id} + self.action_edit_question(cr, uid, [ref('survey_initial_question_company_name')], context = ctx) + self.action_delete_question(cr, uid, [ref('survey_initial_question_company_name')], context = ctx) + self.action_new_question(cr, uid, [], context = ctx) +- + I edit Page of the survey as per requirement. +- + !python {model: survey.question.wiz}: | + name_wiz_obj = self.pool.get('survey.name.wiz') + id = name_wiz_obj.create(cr, uid, {'survey_id': ref("survey_Initial_partner_feedback")}) + ctx = {'active_model':'survey', 'active_id': ref('survey_Initial_partner_feedback'), 'active_ids': [ref('survey_Initial_partner_feedback')], 'page_id': ref('survey_initial_page_Contracts'), 'sur_name_id': id} + self.action_edit_page(cr, uid, [ref('survey_initial_page_Contracts')], context = ctx) + self.action_delete_page(cr, uid, [ref('survey_initial_page_Contracts')], context = ctx) + self.action_new_page(cr, uid, [], context = ctx) +- + In order to send invitation to the users I click on "Send Invitation" wizard. +- + !python {model: survey.send.invitation}: | + context = {'active_model':'survey', 'active_id': ref('survey_Initial_partner_feedback'), 'active_ids': [ref('survey_Initial_partner_feedback')]} + values = self.default_get(cr, uid, ['mail_from', 'mail_subject', 'send_mail_existing', 'mail_subject_existing', 'mail', 'partner_ids', 'send_mail'], context) + values['mail_from'] = 'Surveyor' + new_id = self.create(cr, uid, values) + self.action_send(cr, uid, [new_id], context) +- + I set the value in "Total start survey" field. +- + !python {model: survey}: | + ids = self.write(cr, uid, ref("survey_Initial_partner_feedback"), {'tot_start_survey' : 1}, context) +- + I set the survey in Cancel state. +- + !python {model: survey}: | + sur = self.survey_cancel(cr, uid, [ref("survey_Initial_partner_feedback")], context) +- + I check state of survey is cancel or not. +- + !assert {model: survey, id: survey_Initial_partner_feedback, severity: error, string: Survey should be in cancel state}: + - state == 'cancel' +- + I set the survey in close state. +- + !python {model: survey}: | + sur = self.survey_close(cr, uid, [ref("survey_Initial_partner_feedback")], context) +- + I check state of Survey is close or not. +- + !assert {model: survey, id: survey_Initial_partner_feedback, severity: error, string: Survey should be in close state}: + - state == 'close' \ No newline at end of file diff --git a/addons/survey/test/surey_question_type.yml b/addons/survey/test/surey_question_type.yml new file mode 100644 index 00000000000..4d5bb2053d2 --- /dev/null +++ b/addons/survey/test/surey_question_type.yml @@ -0,0 +1,6 @@ +- + I check the question type of the survey "Initial Partner Feedback". +- + !python {model: survey.question}: | + sur_question = self.on_change_type(cr, uid, [ref("survey_Initial_partner_feedback")], ['multiple_textboxes_diff_type']) + assert sur_question \ No newline at end of file diff --git a/addons/survey/test/survey00.yml b/addons/survey/test/survey00.yml deleted file mode 100644 index ab34f62f65e..00000000000 --- a/addons/survey/test/survey00.yml +++ /dev/null @@ -1,159 +0,0 @@ -- | - Survey Scenario: - In order to check the survey module in OpenERP. -- - I Create the one survey and give survey title "Partner Feedback" and define the survey pages and survey question. -- - I Create "Partner Feedback" survey. -- - !record {model: 'survey', id: survey_partner_0}: - title: 'Partner Feedback' - max_response_limit: 20 -- - I Create "Who are you?" page in "Partner Feedback" survey with title . -- - !record {model: 'survey.page', id: survey_partner_page_0}: - title: 'Who are you?' - survey_id: survey_partner_0 -- - I Create "What is your company name?" question in "Who are you" survey page. -- - !record {model: 'survey.question', id: survey_p_question_0}: - question: 'What is your company name?' - type: single_textbox - sequence: 1 - page_id: survey_partner_page_0 -- - I Create "What is your company size?" question in "Who are you" survey page. -- - !record {model: 'survey.question', id: survey_p_question_1}: - question: 'What is your company size?' - type: multiple_choice_only_one_ans - sequence: 2 - is_require_answer: true - page_id: survey_partner_page_0 -- - I Create "1-50" answer in question "What is your company size?" -- - !record {model: 'survey.answer', id: survey_p_1_1}: - answer: '1 - 50' - sequence: 1 - question_id : survey_p_question_1 -- - I Create "51 - 100" answer in question "What is your company size?" -- - !record {model: 'survey.answer', id: survey_p_1_2}: - answer: '51 - 100' - sequence: 2 - question_id : survey_p_question_1 -- - I Create "100 - 500" answer in question "What is your company size?" -- - !record {model: 'survey.answer', id: survey_p_1_3}: - answer: '100 - 500' - sequence: 3 - question_id : survey_p_question_1 -- - I Create "500 - 1000" answer in question "What is your company size?" -- - !record {model: 'survey.answer', id: survey_p_1_4}: - answer: '500 - 1000' - sequence: 4 - question_id : survey_p_question_1 -- - I Create "> 1000" answer in question "What is your company size?" -- - !record {model: 'survey.answer', id: survey_p_1_5}: - answer: '> 1000' - sequence: 5 - question_id : survey_p_question_1 -- - I Create another "Contract" page in "Partner Feedback" survey. -- - !record {model: 'survey.page', id: survey_partner_page_1}: - title: 'Contract' - survey_id: survey_partner_0 -- - I Create "Which maintenance contract do you sell to your customers." question in "Contract" survey page. -- - !record {model: 'survey.question', id: survey_p_question_3}: - question: 'Which maintenance contract do you sell to your customers.' - type: multiple_choice_only_one_ans - sequence: 1 - page_id: survey_partner_page_1 -- - I Create "OpenERP maintenance contract" answer in question "Which maintenance contract do you sell to your customers." -- - !record {model: 'survey.answer', id: survey_p_3_1}: - answer: 'OpenERP maintenance contract' - sequence: 1 - question_id : survey_p_question_3 -- - I Create "Your own contract, but you buy an OpenERP one" answer in question "Which maintenance contract do you sell to your customers." -- - !record {model: 'survey.answer', id: survey_p_3_2}: - answer: 'Your own contract, but you buy an OpenERP one' - sequence: 2 - question_id : survey_p_question_3 -- - I Create "Your own contract without buying an OpenERP one" answer in question "Which maintenance contract do you sell to your customers." -- - !record {model: 'survey.answer', id: survey_p_3_3}: - answer: 'Your own contract without buying an OpenERP one' - sequence: 3 - question_id : survey_p_question_3 -- - I Create "When do you propose a maintenance contract to your customers?" question in "Contract" survey page. -- - !record {model: 'survey.question', id: survey_p_question_4}: - question: When do you propose a maintenance contract to your customers? - type: multiple_choice_only_one_ans - sequence: 2 - comment_field_type: text - comment_label: Why? - is_require_answer: true - is_comment_require: true - page_id: survey_partner_page_1 -- - I Create "With each integration" answer in question "When do you propose a maintenance contract to your customers?" -- - !record {model: 'survey.answer', id: survey_p_4_1}: - answer: 'With each integration' - sequence: 1 - question_id : survey_p_question_4 -- - I Create "Sometimes" answer in question "When do you propose a maintenance contract to your customers?" -- - !record {model: 'survey.answer', id: survey_p_4_2}: - answer: 'Sometimes' - sequence: 2 - question_id : survey_p_question_4 -- - I Create "Never... " answer in question "When do you propose a maintenance contract to your customers?" -- - !record {model: 'survey.answer', id: survey_p_4_3}: - answer: 'Never... ' - sequence: 3 - question_id : survey_p_question_4 -- - Now Survey set in open state. -- - !python {model: survey}: | - self.survey_open(cr, uid, [ref("survey_partner_0")], context) -- - Give answer of the survey, Run "Answer a Survey" wizard and select the survey and press on start button then run the selected survey. -- - !python {model: survey.name.wiz}: | - id = self.create(cr, uid, {'survey_id': ref("survey_partner_0")}) - self.action_next(cr, uid, [id], context) -- - Give answer of the first and second page in "Partner Feedback" survey. -- - !python {model: survey.question.wiz}: | - ids = self.create(cr, uid, {str(ref("survey_p_question_0")) +"_single" :'Tiny' , str(ref("survey_p_question_1")) + "_selection" :int(ref("survey_p_1_1"))}, context) - ids = self.create(cr, uid, {str(ref("survey_p_question_3")) +"_selection" : int(ref("survey_p_3_1")), str(ref("survey_p_question_4")) +"_selection": int(ref("survey_p_4_1"))},context) -- - Set the value in "Total start survey" field. -- - !python {model: survey}: | - ids = self.write(cr, uid, ref("survey_partner_0"), {'tot_start_survey' : 1}, context) diff --git a/addons/survey/test/survey_report.yml b/addons/survey/test/survey_report.yml index 3b54feb2354..17aa4046762 100644 --- a/addons/survey/test/survey_report.yml +++ b/addons/survey/test/survey_report.yml @@ -1,29 +1,29 @@ - - Print the Survey Browse Response Report through the wizard + I print the Survey Browse Response Report through the wizard. - !python {model: survey}: | ctx={} - ctx.update({'model': 'survey','active_ids': [(6,0,[ref('survey.survey_partner_feedback')])]}) + ctx.update({'model': 'survey','active_ids': [(6,0,[ref('survey_partner_feedback')])]}) data_dict = {'response_ids' : [(6,0,[ref('survey.survey_partner_feedback')])], 'page_number' : True, 'without_pagebreak': True} from tools import test_reports test_reports.try_report_action(cr, uid, 'action_view_survey_print_answer',wiz_data=data_dict, context=ctx, our_module='survey') - - Print the Survey Analysis Report through the wizard + I print the Survey Analysis Report through the wizard. - !python {model: survey}: | ctx={} - ctx.update({'model': 'survey','active_ids': [(6,0,[ref('survey.survey_partner_feedback')])]}) + ctx.update({'model': 'survey','active_ids': [(6,0,[ref('survey_partner_feedback')])]}) data_dict = {'survey_ids' : [(6,0,[ref('survey.survey_partner_feedback')])]} from tools import test_reports test_reports.try_report_action(cr, uid, 'action_view_survey_print_statistics',wiz_data=data_dict, context=ctx, our_module='survey') - - Print the Survey Form Report through the wizard + I print the Survey Form Report through the wizard. - !python {model: survey}: | ctx={} - ctx.update({'model': 'survey','active_ids': [(6,0,[ref('survey.survey_partner_feedback')])]}) + ctx.update({'model': 'survey','active_ids': [(6,0,[ref('survey_partner_feedback')])]}) data_dict = {'survey_ids' : [(6,0,[ref('survey.survey_partner_feedback')])], 'page_number' : True, 'without_pagebreak': True} from tools import test_reports - test_reports.try_report_action(cr, uid, 'action_view_survey_print',wiz_data=data_dict, context=ctx, our_module='survey') + test_reports.try_report_action(cr, uid, 'action_view_survey_print',wiz_data=data_dict, context=ctx, our_module='survey') \ No newline at end of file