mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[MIG] base external dbsource
* Migration of base_external_dbsource to odoo 9.0 * Fixing test error * Moving test from yaml to python * Fixing pylint error in test class * Placeholder added to connection string text zone * improving test coverage OCA Transbot updated translations from Transifex
This commit is contained in:
committed by
Ángel Rivas
parent
89c786c3c1
commit
8f1d5c2eca
58
base_external_dbsource/tests/test_create_dbsource.py
Normal file
58
base_external_dbsource/tests/test_create_dbsource.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.exceptions import Warning as UserError
|
||||
from openerp.tests import common
|
||||
import logging
|
||||
|
||||
|
||||
class TestCreateDbsource(common.TransactionCase):
|
||||
"""Test class for base_external_dbsource."""
|
||||
|
||||
def test_create_dbsource(self):
|
||||
"""source creation should succeed."""
|
||||
dbsource = self.env.ref('base_external_dbsource.demo_postgre')
|
||||
try:
|
||||
dbsource.connection_test()
|
||||
except UserError as e:
|
||||
logging.warning("Log = " + str(e))
|
||||
self.assertTrue(u'Everything seems properly set up!' in str(e))
|
||||
|
||||
def test_create_dbsource_failed(self):
|
||||
"""source creation without connection string should failed."""
|
||||
dbsource = self.env.ref('base_external_dbsource.demo_postgre')
|
||||
|
||||
# Connection without connection_string
|
||||
dbsource.conn_string = ""
|
||||
try:
|
||||
dbsource.connection_test()
|
||||
except UserError as e:
|
||||
logging.warning("Log = " + str(e))
|
||||
self.assertTrue(u'Here is what we got instead:' in str(e))
|
||||
|
||||
def test_create_dbsource_without_connector_failed(self):
|
||||
"""source creation with other connector should failed."""
|
||||
dbsource = self.env.ref('base_external_dbsource.demo_postgre')
|
||||
|
||||
# Connection to mysql
|
||||
try:
|
||||
dbsource.connector = "mysql"
|
||||
dbsource.connection_test()
|
||||
except ValueError as e:
|
||||
logging.warning("Log = " + str(e))
|
||||
self.assertTrue(u'Wrong value for' in str(e))
|
||||
|
||||
# Connection to mysql
|
||||
try:
|
||||
dbsource.connector = "pyodbc"
|
||||
dbsource.connection_test()
|
||||
except ValueError as e:
|
||||
logging.warning("Log = " + str(e))
|
||||
self.assertTrue(u'Wrong value for' in str(e))
|
||||
|
||||
# Connection to oracle
|
||||
try:
|
||||
dbsource.connector = "cx_Oracle"
|
||||
dbsource.connection_test()
|
||||
except ValueError as e:
|
||||
logging.warning("Log = " + str(e))
|
||||
self.assertTrue(u'Wrong value for' in str(e))
|
||||
Reference in New Issue
Block a user