summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2015-09-04 09:30:23 +0200
committerXavier Morel <xmo@odoo.com>2015-09-04 12:59:27 +0200
commit4d44b33ffea0358d3c700a85b48e5eae5224af84 (patch)
treeb51cbb66b57259850634b43d1feb1202f451ff79
parent3658a894bc75724a5b976f3dc1200623e845cb3c (diff)
[IMP] crm & hr_recruitment tours: remove unnecessary tours
To check for result of a tour, would run a second tour performing JSON-RPC calls to check if the first tour had correctly impacted the database. Tours are expensive, an empty tour takes ~6s without doing anything. Replace second tour by regular ORM calls.
-rw-r--r--addons/website_crm/static/src/js/website_crm_tour.js45
-rw-r--r--addons/website_crm/tests/test_website_crm.py14
-rw-r--r--addons/website_hr_recruitment/static/src/js/website_hr_recruitment_tour.js43
-rw-r--r--addons/website_hr_recruitment/tests/test_website_hr_recruitment.py13
4 files changed, 26 insertions, 89 deletions
diff --git a/addons/website_crm/static/src/js/website_crm_tour.js b/addons/website_crm/static/src/js/website_crm_tour.js
index e17c0dafac6..576d5e6c6c9 100644
--- a/addons/website_crm/static/src/js/website_crm_tour.js
+++ b/addons/website_crm/static/src/js/website_crm_tour.js
@@ -42,7 +42,7 @@ odoo.define('website_crm.tour', function(require) {
{
title: "Complete Subject",
element: "textarea[name=description]",
- sampleText: "Even more useless message"
+ sampleText: "### TOUR DATA ###"
},
{
title: "Send the form",
@@ -54,49 +54,6 @@ odoo.define('website_crm.tour', function(require) {
}
]
});
-
- Tour.register({
- id: 'website_crm_tour_results',
- name: "Test the contact us form created records",
- path: '',
- mode: 'test',
- steps: [
- {
- title: "Check crm.lead record has been created",
- waitFor: ".o-apps",
- onload: function (tour) {
- var leadDef = new Model("crm.lead").call(
- "search_read",
- [
- [
- ['contact_name', '=' , 'John Smith'],
- ['phone' , '=' , '118.218'],
- ['email_from' , '=' , 'john@smith.com'],
- ['partner_name', '=' , 'Odoo S.A.'],
- ['name' , '=' , 'Useless message'],
- ['description' , 'like', 'Even more useless message']
- ],
- []
- ]
- );
- var success = function(model, data) {
- if(data.length) {
- $('body').append('<div id="website_form_success_test_tour_'+model+'"></div>');
- }
- };
- leadDef.then(_.bind(success, this, 'crm_lead'));
- }
- },
- {
- title: "Check crm.lead record has been created",
- waitFor: "#website_form_success_test_tour_crm_lead"
- },
- {
- title: "Final Step",
- waitFor: "html"
- }
- ]
- });
});
return {};
diff --git a/addons/website_crm/tests/test_website_crm.py b/addons/website_crm/tests/test_website_crm.py
index ddf627d9fbe..1f684478b81 100644
--- a/addons/website_crm/tests/test_website_crm.py
+++ b/addons/website_crm/tests/test_website_crm.py
@@ -1,7 +1,17 @@
+from openerp.api import Environment
import openerp.tests
@openerp.tests.common.at_install(False)
@openerp.tests.common.post_install(True)
class TestWebsiteCrm(openerp.tests.HttpCase):
def test_tour(self):
- self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('website_crm_tour', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.website_crm_tour", login="admin")
- self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('website_crm_tour_results', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.website_crm_tour_results", login="admin") \ No newline at end of file
+ self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('website_crm_tour', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.website_crm_tour", login='admin')
+
+ # need environment using the test cursor as it's not committed
+ cr = self.registry.cursor()
+ assert cr is self.registry.test_cr
+ env = Environment(cr, self.uid, {})
+ record = env['crm.lead'].search([('description', '=', '### TOUR DATA ###')])
+ assert len(record) == 1
+ assert record.contact_name == 'John Smith'
+ assert record.email_from == 'john@smith.com'
+ assert record.partner_name == 'Odoo S.A.'
diff --git a/addons/website_hr_recruitment/static/src/js/website_hr_recruitment_tour.js b/addons/website_hr_recruitment/static/src/js/website_hr_recruitment_tour.js
index 94297e88746..a85d7760034 100644
--- a/addons/website_hr_recruitment/static/src/js/website_hr_recruitment_tour.js
+++ b/addons/website_hr_recruitment/static/src/js/website_hr_recruitment_tour.js
@@ -32,7 +32,7 @@ odoo.define('website_hr_recruitment.tour', function(require) {
{
title: "Complete Subject",
element: "textarea[name=description]",
- sampleText: "A completely useless message"
+ sampleText: "### HR RECRUITMENT TEST DATA ###"
},
// TODO: Upload a file ?
{
@@ -45,47 +45,6 @@ odoo.define('website_hr_recruitment.tour', function(require) {
}
]
});
-
- Tour.register({
- id: 'website_hr_recruitment_tour_results',
- name: "Check the hr applicants form created records",
- path: '',
- mode: 'test',
- steps: [
- {
- title: "Check hr.applicant record has been created",
- waitFor: ".o-apps",
- onload: function (tour) {
- var hrDef = new Model("hr.applicant").call(
- "search_read",
- [
- [
- ['partner_name' , '=' , 'John Smith'],
- ['partner_phone' , '=' , '118.218'],
- ['email_from' , '=' , 'john@smith.com'],
- ['description' , 'like', 'A completely useless message']
- ],
- []
- ]
- );
- var success = function(model, data) {
- if(data.length) {
- $('body').append('<div id="website_form_success_test_tour_'+model+'"></div>');
- }
- };
- hrDef.then(_.bind(success, this, 'hr_applicant'));
- }
- },
- {
- title: "Check hr.applicant record has been created",
- waitFor: "#website_form_success_test_tour_hr_applicant"
- },
- {
- title: "Final Step",
- waitFor: "html"
- }
- ]
- });
});
return {};
diff --git a/addons/website_hr_recruitment/tests/test_website_hr_recruitment.py b/addons/website_hr_recruitment/tests/test_website_hr_recruitment.py
index d3cb0150bd9..96753811766 100644
--- a/addons/website_hr_recruitment/tests/test_website_hr_recruitment.py
+++ b/addons/website_hr_recruitment/tests/test_website_hr_recruitment.py
@@ -1,7 +1,18 @@
+from openerp.api import Environment
import openerp.tests
@openerp.tests.common.at_install(False)
@openerp.tests.common.post_install(True)
class TestWebsiteHrRecruitmentForm(openerp.tests.HttpCase):
def test_tour(self):
self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('website_hr_recruitment_tour', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.website_hr_recruitment_tour", login="admin")
- self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('website_hr_recruitment_tour_results', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.website_hr_recruitment_tour_results", login="admin")
+
+ # get test cursor to read from same transaction browser is writing to
+ cr = self.registry.cursor()
+ assert cr == self.registry.test_cr
+ env = Environment(cr, self.uid, {})
+
+ record = env['hr.applicant'].search([('description', '=', '### HR RECRUITMENT TEST DATA ###')])
+ assert len(record) == 1
+ assert record.partner_name == "John Smith"
+ assert record.email_from == "john@smith.com"
+ assert record.partner_phone == '118.218'