mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[IMP] base_external_dbsource_sqlite: black, isort, prettier
This commit is contained in:
committed by
Andrea Cattalani
parent
cb88683c9f
commit
2dc342f95b
@@ -6,7 +6,7 @@
|
|||||||
"version": "13.0.1.0.0",
|
"version": "13.0.1.0.0",
|
||||||
"category": "Tools",
|
"category": "Tools",
|
||||||
"author": "Daniel Reis, LasLabs, Odoo Community Association (OCA)",
|
"author": "Daniel Reis, LasLabs, Odoo Community Association (OCA)",
|
||||||
"website": "https://github.com/OCA/server-tools",
|
"website": "https://github.com/OCA/server-backend",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"depends": ["base_external_dbsource"],
|
"depends": ["base_external_dbsource"],
|
||||||
"external_dependencies": {"python": ["sqlalchemy"]},
|
"external_dependencies": {"python": ["sqlalchemy"]},
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ except ImportError:
|
|||||||
|
|
||||||
|
|
||||||
class BaseExternalDbsource(models.Model):
|
class BaseExternalDbsource(models.Model):
|
||||||
""" It provides logic for connection to a SQLite data source. """
|
"""It provides logic for connection to a SQLite data source."""
|
||||||
|
|
||||||
_inherit = "base.external.dbsource"
|
_inherit = "base.external.dbsource"
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ class TestBaseExternalDbsource(common.TransactionCase):
|
|||||||
self.dbsource = self.env.ref("base_external_dbsource_sqlite.demo_sqlite")
|
self.dbsource = self.env.ref("base_external_dbsource_sqlite.demo_sqlite")
|
||||||
|
|
||||||
def test_connection_close_sqlite(self):
|
def test_connection_close_sqlite(self):
|
||||||
""" It should close the connection """
|
"""It should close the connection"""
|
||||||
connection = mock.MagicMock()
|
connection = mock.MagicMock()
|
||||||
res = self.dbsource.connection_close_sqlite(connection)
|
res = self.dbsource.connection_close_sqlite(connection)
|
||||||
self.assertEqual(res, connection.close())
|
self.assertEqual(res, connection.close())
|
||||||
|
|
||||||
def test_connection_open_sqlite(self):
|
def test_connection_open_sqlite(self):
|
||||||
""" It should call SQLAlchemy open """
|
"""It should call SQLAlchemy open"""
|
||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
self.dbsource, "_connection_open_sqlalchemy"
|
self.dbsource, "_connection_open_sqlalchemy"
|
||||||
) as parent_method:
|
) as parent_method:
|
||||||
@@ -30,14 +30,14 @@ class TestBaseExternalDbsource(common.TransactionCase):
|
|||||||
parent_method.assert_called_once_with()
|
parent_method.assert_called_once_with()
|
||||||
|
|
||||||
def test_excecute_sqlite(self):
|
def test_excecute_sqlite(self):
|
||||||
""" It should pass args to SQLAlchemy execute """
|
"""It should pass args to SQLAlchemy execute"""
|
||||||
expect = "sqlquery", "sqlparams", "metadata"
|
expect = "sqlquery", "sqlparams", "metadata"
|
||||||
with mock.patch.object(self.dbsource, "_execute_sqlalchemy") as parent_method:
|
with mock.patch.object(self.dbsource, "_execute_sqlalchemy") as parent_method:
|
||||||
self.dbsource.execute_sqlite(*expect)
|
self.dbsource.execute_sqlite(*expect)
|
||||||
parent_method.assert_called_once_with(*expect)
|
parent_method.assert_called_once_with(*expect)
|
||||||
|
|
||||||
def test_execute_sqlit_without_sqlparams(self):
|
def test_execute_sqlit_without_sqlparams(self):
|
||||||
""" It should pass args to SQLAlchemy execute """
|
"""It should pass args to SQLAlchemy execute"""
|
||||||
expect = "sqlquery", None, "metadata"
|
expect = "sqlquery", None, "metadata"
|
||||||
with mock.patch.object(self.dbsource, "_execute_sqlalchemy") as parent_method:
|
with mock.patch.object(self.dbsource, "_execute_sqlalchemy") as parent_method:
|
||||||
self.dbsource.execute_sqlite(*expect)
|
self.dbsource.execute_sqlite(*expect)
|
||||||
|
|||||||
Reference in New Issue
Block a user