I have been doing unit testing using the TransactionCase class of Odoo Testing. I have tried unit testing a function that uses the params object of the request. I have tried to mock odoo.http.request in several ways:
@patch(“odoo.http.request”).
@patch(“odoo.http.request.params”)
@patch.dict(“odoo.http.request.params”, {“zip_id”: None}, clear=True)
And with all of them I got the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/unittest/mock.py", line 1831, in _inner
self._patch_dict()
File "/usr/local/lib/python3.10/unittest/mock.py", line 1872, in _patch_dict
self.in_dict = _importer(self.in_dict)
File "/usr/local/lib/python3.10/unittest/mock.py", line 1261, in _importer
thing = _dot_lookup(thing, comp, import_path)
File "/usr/local/lib/python3.10/unittest/mock.py", line 1248, in _dot_lookup
return getattr(thing, comp)
File "/usr/local/lib/python3.10/site-packages/werkzeug/local.py", line 432, in __get__
obj = instance._get_current_object()
File "/usr/local/lib/python3.10/site-packages/werkzeug/local.py", line 554, in _get_current_object
return self.__local() # type: ignore
File "/usr/local/lib/python3.10/site-packages/werkzeug/local.py", line 226, in _lookup
raise RuntimeError("object unbound")
RuntimeError: object unbound
Is it possible to access odoo.http.request in a TransactionCase or is it only possible with HttpCase?