[FIX] base_external_dbsource: Reuse Odoo DB settings for tests

Before, postgres configuration was hardcoded. This worked OK for OCA's CI infrastructure, but failed in any other out there that had different defaults.

There's no need to hardcode it; Odoo already must have Postgres connection settings, so let's use those instead. This will make tests testable across different CI infrastructures.

base_external_dbsource 12.0.1.0.1

[UPD] Update base_external_dbsource.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-backend-12.0/server-backend-12.0-base_external_dbsource
Translate-URL: https://translation.odoo-community.org/projects/server-backend-12-0/server-backend-12-0-base_external_dbsource/

[UPD] Update base_external_dbsource.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-backend-12.0/server-backend-12.0-base_external_dbsource
Translate-URL: https://translation.odoo-community.org/projects/server-backend-12-0/server-backend-12-0-base_external_dbsource/
This commit is contained in:
Jairo Llopis
2019-03-28 09:44:19 +00:00
committed by Víctor Martínez
parent 8cc419c652
commit 08543e5602
74 changed files with 715 additions and 18 deletions

View File

@@ -3,6 +3,7 @@
import mock
from odoo.tests import common
from odoo.sql_db import connection_info_for
from ..exceptions import ConnectionFailedError, ConnectionSuccessError
@@ -11,7 +12,22 @@ class TestBaseExternalDbsource(common.TransactionCase):
def setUp(self):
super(TestBaseExternalDbsource, self).setUp()
self.dbsource = self.env.ref('base_external_dbsource.demo_postgre')
# Obtain current odoo instance DB connection settings
connection_info = connection_info_for(self.env.cr.dbname)[1]
# Adapt to the format expected by this module
password = connection_info.get("password", "")
connection_info["password"] = "%s"
connection_info["dbname"] = connection_info["database"]
del connection_info["database"]
# Create a proper dbsource record to test
self.dbsource = self.env["base.external.dbsource"].create({
"conn_string": " ".join(
"%s='%s'" % item for item in connection_info.items()
),
"connector": "postgresql",
"name": "test postgres with current odoo config",
"password": password,
})
def _test_adapter_method(
self, method_name, side_effect=None, return_value=None,