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.
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
import pathlib
|
|
import shutil
|
|
|
|
from odoo_openupgrade_wizard.tools.tools_postgres import ensure_database
|
|
|
|
from . import (
|
|
build_ctx_from_config_file,
|
|
cli_runner_invoke,
|
|
mock_odoo_rpc_url,
|
|
move_to_test_folder,
|
|
)
|
|
|
|
|
|
def test_cli_copydb(mocker):
|
|
move_to_test_folder()
|
|
mock_odoo_rpc_url(mocker)
|
|
|
|
db_name = "database_test_cli___copydb"
|
|
db_dest_name = "database_test_cli___copydb__copy"
|
|
ctx = build_ctx_from_config_file()
|
|
|
|
# Ensure environment is clean
|
|
ensure_database(ctx, db_name, state="absent")
|
|
dest_filestore_path = pathlib.Path(f"./filestore/filestore/{db_dest_name}")
|
|
shutil.rmtree(dest_filestore_path, ignore_errors=True)
|
|
|
|
# Initialize database
|
|
cli_runner_invoke(
|
|
[
|
|
"--log-level=DEBUG",
|
|
"install-from-csv",
|
|
f"--database={db_name}",
|
|
],
|
|
)
|
|
|
|
# Copy database
|
|
cli_runner_invoke(
|
|
[
|
|
"--log-level=DEBUG",
|
|
"copydb",
|
|
f"--source={db_name}",
|
|
f"--dest={db_dest_name}",
|
|
],
|
|
)
|
|
|
|
# check filestore exists
|
|
assert dest_filestore_path.exists()
|
|
|
|
# Delete filestore
|
|
shutil.rmtree(dest_filestore_path)
|