Merge lp:~acsone-openerp/openerp-connector/7.0-bug-1304319 into lp:~openerp-connector-core-editors/openerp-connector/7.0

Proposed by Laurent Mignon (Acsone)
Status: Merged
Approved by: Guewen Baconnier @ Camptocamp
Approved revision: 623
Merged at revision: 630
Proposed branch: lp:~acsone-openerp/openerp-connector/7.0-bug-1304319
Merge into: lp:~openerp-connector-core-editors/openerp-connector/7.0
Diff against target: 36 lines (+17/-1)
2 files modified
connector/session.py (+1/-1)
connector/tests/test_session.py (+16/-0)
To merge this branch: bzr merge lp:~acsone-openerp/openerp-connector/7.0-bug-1304319
Reviewer Review Type Date Requested Status
Sébastien BEAU - http://www.akretion.com not test, code review Approve
Guewen Baconnier @ Camptocamp code review Approve
Laetitia Gangloff (Acsone) (community) code Approve
Review via email: mp+214714@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

For me, it seems ok.

review: Approve (code)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Excellent. Thanks

review: Approve (code review)
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

Great work

review: Approve (not test, code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'connector/session.py'
2--- connector/session.py 2013-09-13 13:22:49 +0000
3+++ connector/session.py 2014-04-08 10:38:23 +0000
4@@ -138,7 +138,7 @@
5 :param values: values to apply on the context
6 :type values: dict
7 """
8- original_context = self._context
9+ original_context = self.context
10 self._context = original_context.copy()
11 self._context.update(values)
12 yield
13
14=== modified file 'connector/tests/test_session.py'
15--- connector/tests/test_session.py 2013-05-02 14:01:27 +0000
16+++ connector/tests/test_session.py 2014-04-08 10:38:23 +0000
17@@ -85,3 +85,19 @@
18 res_users = self.registry('res.users')
19
20 self.assertEqual(self.session.pool.get('res.users'), res_users)
21+
22+ def test_change_context(self):
23+ """
24+ Change the context and check if it is reverted correctly at the end
25+ """
26+ test_key = 'test_key'
27+ self.assertNotIn(test_key, self.session.context)
28+ with self.session.change_context({test_key: 'value'}):
29+ self.assertIn(test_key, self.session.context)
30+ self.assertNotIn(test_key, self.session.context)
31+
32+ #change the context on a session not initialized with a context
33+ session = ConnectorSession(self.cr, self.uid)
34+ with session.change_context({test_key: 'value'}):
35+ self.assertIn(test_key, session.context)
36+ self.assertNotIn(test_key, session.context)