[MIG] base_external_dbsource_sqlite: Migration to 15.0

TT38359
This commit is contained in:
Víctor Martínez
2022-11-18 08:17:06 +01:00
parent f3bb7468e1
commit d4b141ff1d
6 changed files with 34 additions and 35 deletions

View File

@@ -12,7 +12,7 @@ ADAPTER = (
class TestBaseExternalDbsource(common.TransactionCase):
def setUp(self):
super(TestBaseExternalDbsource, self).setUp()
super().setUp()
self.dbsource = self.env.ref("base_external_dbsource_sqlite.demo_sqlite")
def test_connection_close_sqlite(self):
@@ -24,7 +24,7 @@ class TestBaseExternalDbsource(common.TransactionCase):
def test_connection_open_sqlite(self):
"""It should call SQLAlchemy open"""
with mock.patch.object(
self.dbsource, "_connection_open_sqlalchemy"
type(self.dbsource), "_connection_open_sqlalchemy"
) as parent_method:
self.dbsource.connection_open_sqlite()
parent_method.assert_called_once_with()
@@ -32,13 +32,17 @@ class TestBaseExternalDbsource(common.TransactionCase):
def test_excecute_sqlite(self):
"""It should pass args to SQLAlchemy execute"""
expect = "sqlquery", "sqlparams", "metadata"
with mock.patch.object(self.dbsource, "_execute_sqlalchemy") as parent_method:
with mock.patch.object(
type(self.dbsource), "_execute_sqlalchemy"
) as parent_method:
self.dbsource.execute_sqlite(*expect)
parent_method.assert_called_once_with(*expect)
def test_execute_sqlit_without_sqlparams(self):
"""It should pass args to SQLAlchemy execute"""
expect = "sqlquery", None, "metadata"
with mock.patch.object(self.dbsource, "_execute_sqlalchemy") as parent_method:
with mock.patch.object(
type(self.dbsource), "_execute_sqlalchemy"
) as parent_method:
self.dbsource.execute_sqlite(*expect)
parent_method.assert_called_once_with(*expect)