[REM] test_support controller
bzr revid: xmo@openerp.com-20121024110146-bzuf19sfptew0dn0
This commit is contained in:
parent
5743dca47d
commit
1cf9b2a60d
|
@ -1,37 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import xmlrpclib
|
|
||||||
from ..common.openerplib.main import Connector
|
|
||||||
|
|
||||||
execute_map = {}
|
|
||||||
|
|
||||||
class TestConnector(Connector):
|
|
||||||
def db_list_lang(self):
|
|
||||||
return [('en_US', u'Test Language')]
|
|
||||||
|
|
||||||
def common_authenticate(self, db, login, password, environment):
|
|
||||||
return 87539319
|
|
||||||
|
|
||||||
def common_login(self, db, login, password):
|
|
||||||
return self.common_authenticate(db, login, password, {})
|
|
||||||
|
|
||||||
def object_execute_kw(self, db, uid, password, model, method, args, kwargs):
|
|
||||||
if model in execute_map and hasattr(execute_map[model], method):
|
|
||||||
return getattr(execute_map[model], method)(*args, **kwargs)
|
|
||||||
|
|
||||||
raise xmlrpclib.Fault({
|
|
||||||
'model': model,
|
|
||||||
'method': method,
|
|
||||||
'args': args,
|
|
||||||
'kwargs': kwargs
|
|
||||||
}, '')
|
|
||||||
|
|
||||||
def send(self, service_name, method, *args):
|
|
||||||
method_name = '%s_%s' % (service_name, method)
|
|
||||||
if hasattr(self, method_name):
|
|
||||||
return getattr(self, method_name)(*args)
|
|
||||||
|
|
||||||
raise xmlrpclib.Fault({
|
|
||||||
'service': service_name,
|
|
||||||
'method': method,
|
|
||||||
'args': args
|
|
||||||
}, '')
|
|
|
@ -1,42 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from ..common import http, nonliterals
|
|
||||||
from ..controllers.main import Session
|
|
||||||
|
|
||||||
UID = 87539319
|
|
||||||
DB = 'test_db'
|
|
||||||
LOGIN = 'test_login'
|
|
||||||
PASSWORD = 'test_password'
|
|
||||||
CONTEXT = {'lang': 'en_US', 'tz': 'UTC', 'uid': UID}
|
|
||||||
|
|
||||||
def bind(session):
|
|
||||||
session.bind(DB, UID, LOGIN, PASSWORD)
|
|
||||||
session.context = CONTEXT
|
|
||||||
session.build_connection().set_login_info(DB, LOGIN, PASSWORD, UID)
|
|
||||||
|
|
||||||
class TestController(http.Controller):
|
|
||||||
_cp_path = '/tests'
|
|
||||||
|
|
||||||
@http.jsonrequest
|
|
||||||
def add_nonliterals(self, req, domains, contexts):
|
|
||||||
return {
|
|
||||||
'domains': [nonliterals.Domain(req.session, domain)
|
|
||||||
for domain in domains],
|
|
||||||
'contexts': [nonliterals.Context(req.session, context)
|
|
||||||
for context in contexts]
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestSession(Session):
|
|
||||||
_cp_path = '/web/session'
|
|
||||||
|
|
||||||
def session_info(self, req):
|
|
||||||
if not req.session._uid:
|
|
||||||
bind(req.session)
|
|
||||||
|
|
||||||
return {
|
|
||||||
"session_id": req.session_id,
|
|
||||||
"uid": req.session._uid,
|
|
||||||
"context": CONTEXT,
|
|
||||||
"db": req.session._db,
|
|
||||||
"login": req.session._login,
|
|
||||||
}
|
|
Loading…
Reference in New Issue