代码拉取完成,页面将自动刷新
# -*- coding: utf-8 -*-
# Copyright 2016 LasLabs Inc.
import mock
from odoo.tests import common
ADAPTER = ('odoo.addons.base_external_dbsource_odbc.models'
'.base_external_dbsource.pyodbc')
class TestBaseExternalDbsource(common.TransactionCase):
def setUp(self):
super(TestBaseExternalDbsource, self).setUp()
self.dbsource = self.env.ref(
'base_external_dbsource_odbc.demo_odbc',
)
def test_connection_close_pyodbc(self):
""" It should close the connection """
connection = mock.MagicMock()
res = self.dbsource.connection_close_pyodbc(connection)
self.assertEqual(res, connection.close())
@mock.patch(ADAPTER)
def test_connection_open_pyodbc(self, pyodbc):
""" It should open the connection with the full conn string """
self.dbsource.connection_open_pyodbc()
pyodbc.connect.assert_called_once_with(
self.dbsource.conn_string_full,
)
@mock.patch(ADAPTER)
def test_connection_open_pyodbc_return(self, pyodbc):
""" It should return the newly opened connection """
res = self.dbsource.connection_open_pyodbc()
self.assertEqual(res, pyodbc.connect())
def test_execute_pyodbc(self):
""" It should call the generic execute method w/ proper args """
expect = 'sqlquery', 'sqlparams', 'metadata'
with mock.patch.object(self.dbsource, '_execute_generic') as execute:
self.dbsource.execute_pyodbc(*expect)
execute.assert_called_once_with(*expect)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。