TEST - WIP

This commit is contained in:
Sylvain LE GAL 2024-03-23 14:05:26 +01:00
parent 17e8040712
commit c717c04bd0
2 changed files with 7 additions and 7 deletions

View File

@ -122,7 +122,11 @@ def execute_psql_command(
): ):
"""Execute psql request in postgres container with psql_args on database""" """Execute psql request in postgres container with psql_args on database"""
container = get_postgres_container(ctx) container = get_postgres_container(ctx)
logger.warning("DEBUG ========= execute_psql_command")
logger.warning("request: ", request)
logger.warning("database: ", database)
escaped_request = request.replace('"', '\\"') escaped_request = request.replace('"', '\\"')
logger.warning("escaped_request: ", escaped_request)
command = ( command = (
"psql" "psql"
" --username=odoo" " --username=odoo"
@ -130,6 +134,7 @@ def execute_psql_command(
f' --command "{escaped_request}"' f' --command "{escaped_request}"'
f" {' '.join(psql_args)}" f" {' '.join(psql_args)}"
) )
logger.warning("command: ", command)
logger.debug( logger.debug(
"Executing the following command in postgres container\n" "Executing the following command in postgres container\n"
"%s" % (command) "%s" % (command)

View File

@ -2,7 +2,7 @@ from pytest import raises
from odoo_openupgrade_wizard.tools.tools_postgres import ( from odoo_openupgrade_wizard.tools.tools_postgres import (
ensure_database, ensure_database,
execute_psql_command, execute_sql_request,
) )
from . import ( from . import (
@ -38,12 +38,7 @@ def test_cli_psql():
" WHERE state ='installed'" " WHERE state ='installed'"
" AND name='base';" " AND name='base';"
) )
output = execute_psql_command( output = execute_sql_request(ctx, request)
ctx,
request,
database=db_name,
psql_args=("--tuples-only",),
)
assert output.strip() == "base" assert output.strip() == "base"
# test via cli ok # test via cli ok