コード例 #1
0
ファイル: test_ir_sequence.py プロジェクト: CRITEAN/Odoo
def environment():
    """ Return an environment with a new cursor for the current database; the
        cursor is committed and closed after the context block.
    """
    registry = odoo.registry(common.get_db_name())
    with registry.cursor() as cr:
        yield odoo.api.Environment(cr, ADMIN_USER_ID, {})
コード例 #2
0
ファイル: test_uninstall.py プロジェクト: 10537/odoo
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, {})
        cr.commit()
コード例 #3
0
ファイル: test_xmlrpc.py プロジェクト: 0967697922/odoo
 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, 1, 'admin', 'ir.model', 'search', [])
     self.assertIsInstance(ids, list)
     ids = o.execute(db_name, 1, 'admin', 'ir.model', 'search', [], {})
     self.assertIsInstance(ids, list)
コード例 #4
0
ファイル: test_uninstall.py プロジェクト: GabbasovDinar/odoo
    def test_01_install(self):
        """ Check a few things showing the module is installed. """
        with environment() as env:
            module = env["ir.module.module"].search([("name", "=", MODULE)])
            assert len(module) == 1
            module.button_install()
        Registry.new(common.get_db_name(), update_module=True)

        with environment() as env:
            self.assertIn("test_uninstall.model", env.registry)
            self.assertTrue(env["ir.model.data"].search([("module", "=", MODULE)]))
            self.assertTrue(env["ir.model.fields"].search([("model", "=", MODEL)]))
コード例 #5
0
ファイル: test_uninstall.py プロジェクト: 10537/odoo
    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)]))
コード例 #6
0
 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']
     )
コード例 #7
0
 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)
コード例 #8
0
def registry():
    return odoo.registry(common.get_db_name())
コード例 #9
0
 def tearDownClass(cls):
     odoo.registry(common.get_db_name()).leave_test_mode()
     super(TestComputeExampe, cls).tearDownClass()
コード例 #10
0
ファイル: test_xmlrpc.py プロジェクト: GSLabIt/odoo
 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')
コード例 #11
0
 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']
     )
コード例 #12
0
 def test_xmlrpc_name_search(self):
     self.xmlrpc_object.execute(
         common.get_db_name(), self.admin_uid, 'admin',
         'res.partner', 'name_search', "admin"
     )
コード例 #13
0
 def xmlrpc(self, model, method, *args, **kwargs):
     return self.xmlrpc_object.execute_kw(
         common.get_db_name(), self.admin_uid, 'admin',
         model, method, args, kwargs
     )
コード例 #14
0
ファイル: common.py プロジェクト: TpcoDev/CAIT12
    def _setup_registry(class_or_instance):
        ComponentRegistryCase._setup_registry(class_or_instance)

        class_or_instance._service_registry = RestServicesRegistry()
        # take a copy of registered controllers
        controllers = http.controllers_per_module
        http.controllers_per_module = controllers

        class_or_instance._controllers_per_module = copy.deepcopy(
            http.controllers_per_module)
        db_name = get_db_name()

        # makes the test component registry available for the db name
        _component_databases[db_name] = class_or_instance.comp_registry

        # makes the test service registry available for the db name
        class_or_instance._original_services_registry = _rest_services_databases.get(
            db_name, {})
        _rest_services_databases[db_name] = class_or_instance._service_registry

        # build the services and controller of every installed addons
        # but the current addon (when running with pytest/nosetest, we
        # simulate the --test-enable behavior by excluding the current addon
        # which is in 'to install' / 'to upgrade' with --test-enable).
        current_addon = _get_addon_name(class_or_instance.__module__)

        with new_rollbacked_env() as env:
            RestServiceRegistration = env["rest.service.registration"]
            RestServiceRegistration.build_registry(
                class_or_instance._service_registry,
                states=("installed", ),
                exclude_addons=[current_addon],
            )
            RestServiceRegistration._build_controllers_routes(
                class_or_instance._service_registry)

        # register our components
        class_or_instance.comp_registry.load_components("base_rest")

        # Define a base test controller here to avoid to have this controller
        # registered outside tests
        class_or_instance._collection_name = "base.rest.test"

        class BaseTestController(RestController):
            _root_path = "/test_controller/"
            _collection_name = class_or_instance._collection_name
            _default_auth = "public"

            @http.route("/my_controller_route_without_auth")
            def my_controller_route_without_auth(self):
                return {}

            @http.route("/my_controller_route_with_auth_public", auth="public")
            def my_controller_route_with_auth_public(self):
                return {}

            @http.route("/my_controller_route_without_auth_2", auth=None)
            def my_controller_route_without_auth_2(self):
                return {}

        class_or_instance._BaseTestController = BaseTestController
        class_or_instance._controller_route_method_names = {
            "my_controller_route_without_auth",
            "my_controller_route_with_auth_public",
            "my_controller_route_without_auth_2",
        }
コード例 #15
0
 def test_authenticate(self):
     db_name = common.get_db_name()
     env = dict(base_location="http://build-123.runbot.example.com", )
     uid = self.registry['res.users'].authenticate(db_name, 'admin',
                                                   'admin', env)
     self.assertEqual(uid, 1)
コード例 #16
0
ファイル: test_xmlrpc.py プロジェクト: 0967697922/odoo
 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, 1)
コード例 #17
0
 def setUpClass(cls):
     super(TestComputeExampe, cls).setUpClass()
     odoo.registry(common.get_db_name()).enter_test_mode()
コード例 #18
0
ファイル: test_db_cursor.py プロジェクト: 10537/odoo
def registry():
    return odoo.registry(common.get_db_name())
コード例 #19
0
 def open_session(self):
     self.session = Session(None, None, parse_config=False)
     self.session.open(db=get_db_name())