odoo-openupgrade-wizard/tests/cli_20_install_from_csv_test.py
Rémy Taymans a0307847b9 Allow mocking the ODOO_RPC_URL for testing
Depending of the test environment, the url of the odoo container may
change.

Using pytest in a local shell, Odoo will be available at 0.0.0.0
address.

Using pytest in a docker-in-docker environment, the url for the Odoo
container will be exposed on a different address depending on the
configuration of the docker-in-docker environment.

The mock check whether the user has configured a différent URL for the
Odoo RPC calls, and set it accordingly using mock feature.

In the gitlab-ci, the ODOO_RPC_URL should be used to set the correct
address for the RPC calls.
2023-11-09 16:21:20 +01:00

53 lines
1.2 KiB
Python

from odoo_openupgrade_wizard.tools.tools_postgres import (
ensure_database,
execute_sql_request,
)
from . import (
build_ctx_from_config_file,
cli_runner_invoke,
mock_odoo_rpc_url,
move_to_test_folder,
)
def test_cli_install_from_csv(mocker):
move_to_test_folder()
mock_odoo_rpc_url(mocker)
# Initialize database
db_name = "database_test_cli___install_from_csv"
ctx = build_ctx_from_config_file()
ensure_database(ctx, db_name, state="absent")
cli_runner_invoke(
[
"--log-level=DEBUG",
"install-from-csv",
"--database=%s" % db_name,
],
)
# Ensure that 'base' is installed
request = (
"SELECT count(*)"
" FROM ir_module_module"
" WHERE state ='installed'"
" AND name in ('base');"
)
module_qty = int(execute_sql_request(ctx, request, database=db_name)[0][0])
assert module_qty == 1
# Ensure that 'account' is not installed
request = (
"SELECT count(*)"
" FROM ir_module_module"
" WHERE state ='installed'"
" AND name in ('account');"
)
module_qty = int(execute_sql_request(ctx, request, database=db_name)[0][0])
assert module_qty == 0