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.

41 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_firebird.models'
  6. '.base_external_dbsource.fdb')
  7. class TestBaseExternalDbsource(common.TransactionCase):
  8. def setUp(self):
  9. super(TestBaseExternalDbsource, self).setUp()
  10. self.dbsource = self.env.ref(
  11. 'base_external_dbsource_firebird.demo_firebird',
  12. )
  13. def test_connection_close_fdb(self):
  14. """ It should close the connection """
  15. connection = mock.MagicMock()
  16. res = self.dbsource.connection_close_fdb(connection)
  17. self.assertEqual(res, connection.close())
  18. @mock.patch(ADAPTER)
  19. def test_connection_open_fdb(self, fdb):
  20. """ It should open the connection with the split conn string """
  21. self.dbsource.conn_string = 'User=User;'
  22. self.dbsource.connection_open_fdb()
  23. fdb.connect.assert_called_once_with(**{
  24. 'user': 'User',
  25. 'password': 'password',
  26. })
  27. @mock.patch(ADAPTER)
  28. def test_connection_open_fdb_return(self, fdb):
  29. """ It should return the newly opened connection """
  30. res = self.dbsource.connection_open_fdb()
  31. self.assertEqual(res, fdb.connect())