mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[IMP] base_external_dbsource: Refactor & Split by source
* Heavily refactor code for reusability * Split all sources into independent modules * Add more test coverage * Add CRUD methods * Add iterator execute return to roadmap [UPD] Update base_external_dbsource_mssql.pot
This commit is contained in:
committed by
sergio-teruel
parent
98c0bb00b6
commit
a0d878cc84
3
base_external_dbsource_mssql/tests/__init__.py
Normal file
3
base_external_dbsource_mssql/tests/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from . import test_base_external_dbsource
|
||||
@@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
|
||||
import mock
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
ADAPTER = ('odoo.addons.base_external_dbsource_mssql.models'
|
||||
'.base_external_dbsource.pymssql')
|
||||
|
||||
|
||||
class TestBaseExternalDbsource(common.TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestBaseExternalDbsource, self).setUp()
|
||||
self.dbsource = self.env.ref(
|
||||
'base_external_dbsource_mssql.demo_mssql',
|
||||
)
|
||||
|
||||
def test_connection_close_mssql(self):
|
||||
""" It should close the connection """
|
||||
connection = mock.MagicMock()
|
||||
res = self.dbsource.connection_close_mssql(connection)
|
||||
self.assertEqual(res, connection.close())
|
||||
|
||||
def test_connection_open_mssql(self):
|
||||
""" It should call SQLAlchemy open """
|
||||
with mock.patch.object(
|
||||
self.dbsource, '_connection_open_sqlalchemy'
|
||||
) as parent_method:
|
||||
self.dbsource.connection_open_mssql()
|
||||
parent_method.assert_called_once_with()
|
||||
|
||||
def test_excecute_mssql(self):
|
||||
""" It should pass args to SQLAlchemy execute """
|
||||
expect = 'sqlquery', 'sqlparams', 'metadata'
|
||||
with mock.patch.object(
|
||||
self.dbsource, '_execute_sqlalchemy'
|
||||
) as parent_method:
|
||||
self.dbsource.execute_mssql(*expect)
|
||||
parent_method.assert_called_once_with(*expect)
|
||||
Reference in New Issue
Block a user