Skip to content

Commit

Permalink
Merge pull request #157 from gisce/push_WebserviceTracker
Browse files Browse the repository at this point in the history
Simulate webservice call and make api and api.db aviable on objects under testing context
  • Loading branch information
polsala authored Dec 11, 2024
2 parents ad11ec8 + d8bc370 commit 0c3b4b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion destral/openerp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ def __init__(self, **kwargs):
if hasattr(tools.config, 'parse'):
tools.config.parse()
from tools import config as default_config
from ctx import _cursor_context
from ctx import _cursor_context, _ws_info
self.config = update_config(default_config, **config)
import pooler
import workflow
self.pooler = pooler
self.db = None
self.pool = None
self.cursor_stack = _cursor_context
self.ws_stack = _ws_info
if 'db_name' in config:
try:
self.db_name = config['db_name']
Expand Down
8 changes: 8 additions & 0 deletions destral/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Transaction(local):
cursor = None
user = None
context = None
ws = None

def __init__(self):
pass
Expand All @@ -48,6 +49,9 @@ def start(self, database_name, user=1, context=None):
self.pool = self.service.pool
self.cursor = self.service.db.cursor()
self.service.cursor_stack.push(self.cursor)
from tools import WebServiceTracker
self.ws = WebServiceTracker(db=self.service.db)
self.service.ws_stack.push(self.ws)
self.user = user
try:
receivers = DB_CURSOR_EXECUTE.receivers
Expand All @@ -63,6 +67,9 @@ def stop(self):
if self.cursor is not None:
self.service.cursor_stack.pop()
self.cursor.close()
if self.ws is not None:
self.service.ws_stack.pop()
self.ws = None
self.service = None
self.cursor = None
self.user = None
Expand All @@ -87,6 +94,7 @@ def __exit__(self, type, value, traceback):
def _assert_stopped(self, deep=False):
try:
assert self.service is None
assert self.ws is None
assert self.database is None
assert self.cursor is None
assert self.pool is None
Expand Down

0 comments on commit 0c3b4b5

Please sign in to comment.