You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 LasLabs Inc.
  3. import mock
  4. from odoo.tests import common
  5. ADAPTER = ('odoo.addons.base_external_dbsource_mssql.models'
  6. '.base_external_dbsource.pymssql')
  7. class TestBaseExternalDbsource(common.TransactionCase):
  8. def setUp(self):
  9. super(TestBaseExternalDbsource, self).setUp()
  10. self.dbsource = self.env.ref(
  11. 'base_external_dbsource_mssql.demo_mssql',
  12. )
  13. def test_connection_close_mssql(self):
  14. """ It should close the connection """
  15. connection = mock.MagicMock()
  16. res = self.dbsource.connection_close_mssql(connection)
  17. self.assertEqual(res, connection.close())
  18. def test_connection_open_mssql(self):
  19. """ It should call SQLAlchemy open """
  20. with mock.patch.object(
  21. self.dbsource, '_connection_open_sqlalchemy'
  22. ) as parent_method:
  23. self.dbsource.connection_open_mssql()
  24. parent_method.assert_called_once_with()
  25. def test_excecute_mssql(self):
  26. """ It should pass args to SQLAlchemy execute """
  27. expect = 'sqlquery', 'sqlparams', 'metadata'
  28. with mock.patch.object(
  29. self.dbsource, '_execute_sqlalchemy'
  30. ) as parent_method:
  31. self.dbsource.execute_mssql(*expect)
  32. parent_method.assert_called_once_with(*expect)