Skip to content

Commit e0abdb3

Browse files
committed
Fix context_get arguments
1 parent 9af0efc commit e0abdb3

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Changelog
55
2.x.x (unreleased)
66
~~~~~~~~~~~~~~~~~~
77

8+
* Fix `context_get` arguments.
9+
810
* Fix PyPI classifiers.
911

1012
* Update documentation.

odooly.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@ def _auth(self, user, password, context):
611611
self.session_info = info
612612
user_context = info.get('user_context') or {}
613613
if not user_context and self.client._object:
614-
user_context = self.client._object.execute_kw(self.db_name, uid, password, 'res.users', 'context_get')
614+
args = self.db_name, uid, password, 'res.users', 'context_get', ()
615+
user_context = self.client._object.execute_kw(*args)
615616
if context:
616617
user_context = {**user_context, **context}
617618
return (uid, password, user_context)

tests/_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def OBJ(model, method, *params, **kw):
2121
kw['context'] = sample_context
2222
elif kw['context'] is None:
2323
del kw['context']
24-
extra = (params, kw) if kw else (params,) if params else ()
24+
extra = (params, kw) if kw else (params,)
2525
return ('object.execute_kw', sentinel.AUTH, model, method, *extra)
2626

2727

tests/test_client.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def test_service_openerp_client(self, server_version=11.0):
130130
if server_version <= 8.0:
131131
expected_calls += [
132132
call('login', ('newdb', 'usr', 'pss')),
133-
call('execute_kw', ('newdb', 1, 'pss', 'res.users', 'context_get'))
133+
call('execute_kw', ('newdb', 1, 'pss', 'res.users', 'context_get', ()))
134134
]
135135
else:
136136
# server_version, list, web_auth
@@ -185,7 +185,7 @@ def test_create(self):
185185
client = odooly.Client(url_xmlrpc, 'newdb', 'usr', 'pss')
186186
expected_calls = self.startup_calls + (
187187
call.common.login('newdb', 'usr', 'pss'),
188-
call.object.execute_kw('newdb', 1, 'pss', 'res.users', 'context_get'),
188+
call.object.execute_kw('newdb', 1, 'pss', 'res.users', 'context_get', ()),
189189
)
190190
self.assertIsInstance(client, odooly.Client)
191191
self.assertCalls(*expected_calls)
@@ -216,7 +216,7 @@ def test_create_getpass(self):
216216
self.service.common.login.return_value = 17
217217
getpass.reset_mock()
218218
expected_calls = expected_calls + (
219-
call.object.execute_kw('database', 17, 'password', 'res.users', 'context_get'),
219+
call.object.execute_kw('database', 17, 'password', 'res.users', 'context_get', ()),
220220
)
221221

222222
client = odooly.Client(self.server, 'database', 'usr')
@@ -234,7 +234,7 @@ def test_create_with_cache(self):
234234
client = odooly.Client(url_xmlrpc, 'database', 'usr')
235235
self.assertIsInstance(client, odooly.Client)
236236
self.assertCalls(*(self.startup_calls + (
237-
call.object.execute_kw('database', 1, 'password', 'res.users', 'context_get'),
237+
call.object.execute_kw('database', 1, 'password', 'res.users', 'context_get', ()),
238238
)))
239239
self.assertOutput('')
240240

@@ -260,7 +260,7 @@ def test_create_from_config(self):
260260
read_config.reset_mock()
261261
getpass.reset_mock()
262262
expected_calls = expected_calls + (
263-
call.object.execute_kw('database', 17, 'password', 'res.users', 'context_get'),
263+
call.object.execute_kw('database', 17, 'password', 'res.users', 'context_get', ()),
264264
)
265265

266266
client = odooly.Client.from_config('test')
@@ -369,11 +369,11 @@ def test_create_database(self):
369369
if float(self.server_version) <= 8.0:
370370
expected_calls[2:2] = [
371371
call.common.login('db1', 'admin', 'admin'),
372-
call.object.execute_kw('db1', 1, 'admin', 'res.users', 'context_get'),
372+
call.object.execute_kw('db1', 1, 'admin', 'res.users', 'context_get', ()),
373373
]
374374
expected_calls[6:] = [
375375
call.common.login('db2', 'admin', 'secret'),
376-
call.object.execute_kw('db2', 1, 'secret', 'res.users', 'context_get'),
376+
call.object.execute_kw('db2', 1, 'secret', 'res.users', 'context_get', ()),
377377
]
378378

379379
self.assertRaises(
@@ -570,11 +570,9 @@ def test_sudo(self):
570570
OBJ('ir.model.access', 'check', 'res.users', 'write'),
571571
OBJ('res.users', 'search', [('login', '=', 'guest')]),
572572
OBJ('res.users', 'read', 123, ['id', 'login', 'password']),
573-
('object.execute_kw', self.database, 123, 'xxx',
574-
'res.users', 'context_get'),
575-
576-
('object.execute_kw', self.database, 1, 'passwd',
577-
'res.users', 'context_get'),
573+
('object.execute_kw', self.database, 123, 'xxx', 'res.users', 'context_get', ()),
574+
#
575+
('object.execute_kw', self.database, 1, 'passwd', 'res.users', 'context_get', ()),
578576
OBJ('ir.model.access', 'check', 'res.users', 'write', context=ctx_lang),
579577
('object.execute_kw', self.database, 123, 'xxx',
580578
'ir.model.access', 'check', ('res.users', 'write'), {'context': ctx_lang}),

tests/test_interact.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def test_main(self):
5555
self.assertEqual(sys.ps2, ' ... ')
5656
expected_calls = self.startup_calls + (
5757
('common.login', 'database', 'usr', 'password'),
58-
('object.execute_kw', 'database', 17, 'password', 'res.users', 'context_get'),
58+
('object.execute_kw', 'database', 17, 'password', 'res.users', 'context_get', ()),
5959
('object.execute_kw', 'database', 17, 'password',
6060
'ir.model.access', 'check', ('res.users', 'write')),
6161
('common.login', 'database', 'gaspard', 'password'),
62-
('object.execute_kw', 'database', 51, 'password', 'res.users', 'context_get'),
62+
('object.execute_kw', 'database', 51, 'password', 'res.users', 'context_get', ()),
6363
)
6464
self.assertCalls(*expected_calls)
6565
self.assertEqual(getpass.call_count, 2)
@@ -125,7 +125,7 @@ def usr17(model, method, *params):
125125

126126
expected_calls = self.startup_calls + (
127127
('common.login', 'database', 'usr', 'passwd'),
128-
('object.execute_kw', 'database', 17, 'passwd', 'res.users', 'context_get'),
128+
('object.execute_kw', 'database', 17, 'passwd', 'res.users', 'context_get', ()),
129129
usr17('ir.model', 'search',
130130
[('model', 'like', 'res.company')]),
131131
usr17('ir.model', 'read', 42, ('model',)),

tests/test_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ def guest(model, method, *params, **kw):
13271327
kw['context'] = {'lang': 'en_US', 'tz': 'Europe/Zurich'}
13281328
elif kw['context'] is None:
13291329
del kw['context']
1330-
extra = (params, kw) if kw else (params,) if params else ()
1330+
extra = (params, kw) if kw else (params,)
13311331
return ('object.execute_kw', self.database, 1001, 'v_password',
13321332
model, method, *extra)
13331333

0 commit comments

Comments
 (0)