Skip to content

Commit a1d99d9

Browse files
[MIG] base_rest: Migration to 19.0
1 parent 7a437be commit a1d99d9

7 files changed

Lines changed: 16 additions & 23 deletions

File tree

base_rest/__manifest__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
"assets": {
2121
"web.assets_frontend": [
2222
"base_rest/static/src/scss/base_rest.scss",
23-
"base_rest/static/src/js/swagger_ui.js",
24-
"base_rest/static/src/js/swagger.js",
2523
],
2624
},
2725
"external_dependencies": {
@@ -33,5 +31,4 @@
3331
"apispec",
3432
]
3533
},
36-
"installable": True,
3734
}

base_rest/http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
ValidationError,
3030
)
3131
from odoo.http import (
32-
CSRF_FREE_METHODS,
3332
MISSING_CSRF_WARNING,
33+
SAFE_HTTP_METHODS,
3434
Dispatcher,
3535
SessionExpiredException,
3636
request,
@@ -162,7 +162,7 @@ def dispatch(self, endpoint, args):
162162

163163
# Check for CSRF token for relevant requests
164164
if (
165-
self.request.httprequest.method not in CSRF_FREE_METHODS
165+
self.request.httprequest.method not in SAFE_HTTP_METHODS
166166
and endpoint.routing.get("csrf", True)
167167
):
168168
token = params.pop("csrf_token", None)

base_rest/models/rest_service_registration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ def build_registry(self, services_registry, states=None, exclude_addons=None):
189189
# dependencies to ensure that controllers defined in a more
190190
# specialized addon and overriding more generic one takes precedences
191191
# on the generic one into the registry
192-
graph = odoo.modules.graph.Graph()
193-
graph.add_module(self.env.cr, "base")
192+
graph = odoo.modules.module_graph.ModuleGraph(self.env.cr)
193+
graph.extend(["base"])
194194

195195
query = "SELECT name FROM ir_module_module WHERE state IN %s "
196196
params = [tuple(states)]
@@ -200,7 +200,7 @@ def build_registry(self, services_registry, states=None, exclude_addons=None):
200200
self.env.cr.execute(query, params)
201201

202202
module_list = [name for (name,) in self.env.cr.fetchall() if name not in graph]
203-
graph.add_modules(self.env.cr, module_list)
203+
graph.extend(module_list)
204204

205205
for module in graph:
206206
self.load_services(module.name, services_registry)

base_rest/tests/common.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def _setup_registry(class_or_instance):
9595
)
9696

9797
# register our components
98+
class_or_instance.comp_registry.load_components("component")
9899
class_or_instance.comp_registry.load_components("base_rest")
99100

100101
# Define a base test controller here to avoid to have this controller
@@ -239,15 +240,15 @@ def setUpClass(cls):
239240

240241

241242
class BaseRestCase(TransactionComponentCase, RegistryMixin):
242-
@classmethod
243-
def setUpClass(cls):
244-
super().setUpClass()
245-
cls.setUpRegistry()
246-
cls.base_url = cls.env["ir.config_parameter"].get_param("web.base.url")
247-
cls.registry.enter_test_mode(cls.env.cr)
243+
# pylint: disable=W8106
244+
def setUp(self):
245+
super().setUp()
246+
self.setUpRegistry()
247+
self.base_url = self.env["ir.config_parameter"].get_param("web.base.url")
248+
self.registry_enter_test_mode(register_cleanup=False)
248249

249250
# pylint: disable=W8110
250251
@classmethod
251252
def tearDownClass(cls):
252-
cls.registry.leave_test_mode()
253+
cls.registry_leave_test_mode()
253254
super().tearDownClass()

base_rest/tests/test_openapi_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
33

44
from odoo.addons.component.core import Component
5-
from odoo.addons.website.tools import MockRequest
5+
from odoo.addons.http_routing.tests.common import MockRequest
66

77
from .. import restapi
88
from .common import TransactionRestServiceRegistryCase

base_rest/tests/test_service_context_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2021 ACSONE SA/NV
22
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
33
from odoo.addons.component.core import Component
4-
from odoo.addons.website.tools import MockRequest
4+
from odoo.addons.http_routing.tests.common import MockRequest
55

66
from .. import restapi
77
from .common import BaseRestCase, TransactionRestServiceRegistryCase
@@ -147,4 +147,4 @@ def get(self, _id):
147147
class CommonCase(BaseRestCase):
148148
# dummy test method to pass codecov
149149
def test_04(self):
150-
self.assertEqual(self.registry.test_cr, self.cr)
150+
self.assertEqual(self.registry.db_name, self.cr.dbname)

requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)