def environment(): """ Return an environment with a new cursor for the current database; the cursor is committed and closed after the context block. """ reg = registry(common.get_db_name()) with reg.cursor() as cr: yield api.Environment(cr, SUPERUSER_ID, {})
def setUp(self): super(TestError, self).setUp() uid = self.ref("base.user_admin") self.rpc = partial(self.xmlrpc_object.execute, common.get_db_name(), uid, "admin") # Reset the admin's lang to avoid breaking tests due to admin not in English self.rpc("res.users", "write", [uid], {"lang": False})
def test_xmlrpc_ir_model_search(self): """ Try a search on the object service. """ o = self.xmlrpc_object db_name = common.get_db_name() ids = o.execute(db_name, self.admin_uid, 'admin', 'ir.model', 'search', []) self.assertIsInstance(ids, list) ids = o.execute(db_name, self.admin_uid, 'admin', 'ir.model', 'search', [], {}) self.assertIsInstance(ids, list)
def test_02_uninstall(self): """ Check a few things showing the module is uninstalled. """ with environment() as env: module = env['ir.module.module'].search([('name', '=', MODULE)]) assert len(module) == 1 module.button_uninstall() Registry.new(common.get_db_name(), update_module=True) with environment() as env: self.assertNotIn('test_uninstall.model', env.registry) self.assertFalse(env['ir.model.data'].search([('module', '=', MODULE)])) self.assertFalse(env['ir.model.fields'].search([('model', '=', MODEL)]))
def test_search(self): dbname = common.get_db_name() admin_uid = self.env.ref('base.user_admin').id website = self.env['website'].get_current_website() robot = self.xmlrpc_object.execute( dbname, admin_uid, 'admin', 'website', 'search_pages', [website.id], 'info' ) self.assertEqual(robot, [{'loc': '/website/info'}]) pages = self.xmlrpc_object.execute( dbname, admin_uid, 'admin', 'website', 'search_pages', [website.id], 'page' ) self.assertEqual( [{'loc': p['loc']} for p in pages], [{'loc': '/page_1'}] )
def test_jsonrpc_name_search(self): # well that's some sexy sexy call right there self._json_call(common.get_db_name(), self.admin_uid, 'admin', 'res.partner', 'name_search', 'admin')
def test_jsonrpc_read_group(self): self._json_call(common.get_db_name(), self.admin_uid, 'admin', 'res.partner', 'read_group', [], ['is_company', 'color'], ['parent_id'])
def test_xmlrpc_name_search(self): self.xmlrpc_object.execute(common.get_db_name(), self.admin_uid, 'admin', 'res.partner', 'name_search', "admin")
def test_xmlrpc_read_group(self): groups = self.xmlrpc_object.execute(common.get_db_name(), self.admin_uid, 'admin', 'res.partner', 'read_group', [], ['is_company', 'color'], ['parent_id'])
def test_01_xmlrpc_login(self): """ Try to login on the common service. """ db_name = common.get_db_name() uid = self.xmlrpc_common.login(db_name, 'admin', 'admin') self.assertEqual(uid, self.admin_uid)
def registry(): return harpiya.registry(common.get_db_name())