[WIP] refactor simplify tests

This commit is contained in:
Sylvain LE GAL 2022-05-19 17:33:48 +02:00
parent 35dc4fd767
commit fca87d1483
15 changed files with 56 additions and 89 deletions

3
.gitignore vendored
View File

@ -4,6 +4,5 @@ __pycache__
.tox .tox
.coverage .coverage
.pytest_cache .pytest_cache
/tests/output_A/* /tests/output/*
/tests/output_B/*
log/ log/

View File

@ -37,11 +37,11 @@ pytest:
- echo $PYTHONPATH - echo $PYTHONPATH
- poetry run pytest --version - poetry run pytest --version
- poetry run pytest --verbose --verbose tests/cli_A_init_test.py - poetry run pytest --verbose --verbose tests/cli_01_init_test.py
# - poetry run pytest --verbose --verbose tests/cli_B_01_get_code_test.py - poetry run pytest --verbose --verbose tests/cli_02_get_code_test.py
# - poetry run pytest --verbose --verbose tests/cli_B_02_docker_build_test.py - poetry run pytest --verbose --verbose tests/cli_03_docker_build_test.py
# - poetry run pytest --verbose --verbose tests/cli_B_03_run_test.py - poetry run pytest --verbose --verbose tests/cli_04_run_test.py
# - poetry run pytest --verbose --verbose tests/cli_B_04_execute_script_python_test.py - poetry run pytest --verbose --verbose tests/cli_05_execute_script_python_test.py
# - poetry run pytest --verbose --verbose tests/cli_B_05_execute_script_sql_test.py - poetry run pytest --verbose --verbose tests/cli_06_execute_script_sql_test.py
# - poetry run pytest --verbose --verbose tests/cli_B_06_upgrade_test.py - poetry run pytest --verbose --verbose tests/cli_07_upgrade_test.py
# - poetry run pytest --verbose --verbose tests/cli_B_07_generate_module_analysis_test.py - poetry run pytest --verbose --verbose tests/cli_08_generate_module_analysis_test.py

View File

@ -1,2 +1,2 @@
[pytest] [pytest]
norecursedirs = tests/output_* norecursedirs = tests/output/*

View File

@ -7,8 +7,8 @@ from . import cli_runner_invoke
def test_cli_init(): def test_cli_init():
output_folder_path = Path("./tests/output_A").absolute() output_folder_path = Path("./tests/output").absolute()
expected_folder_path = Path("./tests/output_A_expected").absolute() expected_folder_path = Path("./tests/output_expected").absolute()
mkdir([output_folder_path, "--parents"]) mkdir([output_folder_path, "--parents"])
cli_runner_invoke( cli_runner_invoke(
@ -17,10 +17,9 @@ def test_cli_init():
"--env-folder=%s" % output_folder_path, "--env-folder=%s" % output_folder_path,
"init", "init",
"--project-name=test-cli", "--project-name=test-cli",
"--initial-release=9.0", "--initial-release=13.0",
"--final-release=12.0", "--final-release=14.0",
"--extra-repository=" "--extra-repository=OCA/web",
"OCA/web,OCA/server-tools,GRAP/grap-odoo-incubator",
] ]
) )

View File

@ -1,27 +1,10 @@
from pathlib import Path from pathlib import Path
from plumbum.cmd import mkdir
from . import cli_runner_invoke from . import cli_runner_invoke
def test_cli_get_code(): def test_cli_get_code():
output_folder_path = Path("./tests/output_B").absolute() output_folder_path = Path("./tests/output").absolute()
mkdir([output_folder_path, "--parents"])
# We initialize an env with only two releases to avoid to git clone
# large data
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"init",
"--project-name=test-cli",
"--initial-release=13.0",
"--final-release=14.0",
"--extra-repository=OCA/web",
]
)
cli_runner_invoke( cli_runner_invoke(
[ [

View File

@ -6,7 +6,7 @@ from . import cli_runner_invoke
def test_cli_docker_build(): def test_cli_docker_build():
output_folder_path = Path("./tests/output_B").absolute() output_folder_path = Path("./tests/output").absolute()
cli_runner_invoke( cli_runner_invoke(
[ [

View File

@ -7,7 +7,7 @@ from . import build_ctx_from_config_file, cli_runner_invoke
def test_cli_run(): def test_cli_run():
output_folder_path = Path("./tests/output_B").absolute() output_folder_path = Path("./tests/output").absolute()
ctx = build_ctx_from_config_file(output_folder_path) ctx = build_ctx_from_config_file(output_folder_path)
db_name = "database_test_cli_run" db_name = "database_test_cli_run"
cli_runner_invoke( cli_runner_invoke(

View File

@ -4,10 +4,10 @@ from . import cli_runner_invoke
def test_cli_execute_script_python(): def test_cli_execute_script_python():
output_folder_path = Path("./tests/output_B").absolute() output_folder_path = Path("./tests/output").absolute()
extra_script_path = Path( extra_script_path = Path(
"./tests/extra_script_B/post-migration-custom_test.py" "./tests/extra_script/post-migration-custom_test.py"
).absolute() ).absolute()
db_name = "database_test_cli_execute_script_python" db_name = "database_test_cli_execute_script_python"

View File

@ -10,10 +10,10 @@ from . import build_ctx_from_config_file, cli_runner_invoke
def test_cli_execute_script_sql(): def test_cli_execute_script_sql():
output_folder_path = Path("./tests/output_B").absolute() output_folder_path = Path("./tests/output").absolute()
extra_script_path = Path( extra_script_path = Path(
"./tests/extra_script_B/pre-migration-custom_test.sql" "./tests/extra_script/pre-migration-custom_test.sql"
).absolute() ).absolute()
destination_path = output_folder_path / "scripts/step_01__update__13.0" destination_path = output_folder_path / "scripts/step_01__update__13.0"

View File

@ -9,7 +9,7 @@ from . import build_ctx_from_config_file, cli_runner_invoke
def test_cli_upgrade(): def test_cli_upgrade():
output_folder_path = Path("./tests/output_B").absolute() output_folder_path = Path("./tests/output").absolute()
db_name = "database_test_cli_upgrade" db_name = "database_test_cli_upgrade"

View File

@ -8,7 +8,7 @@ from . import build_ctx_from_config_file, cli_runner_invoke
def test_cli_generate_module_analysis(): def test_cli_generate_module_analysis():
# TODO, fixme, this test is not working for the time being # TODO, fixme, this test is not working for the time being
return return
output_folder_path = Path("./tests/output_B").absolute() output_folder_path = Path("./tests/output").absolute()
db_name = "database_test_cli_cli_generate_module_analysis" db_name = "database_test_cli_cli_generate_module_analysis"
ctx = build_ctx_from_config_file(output_folder_path) ctx = build_ctx_from_config_file(output_folder_path)

View File

@ -1,46 +0,0 @@
project_name: test-cli
postgres_image_name: postgres:13
postgres_container_name: test-cli-db
odoo_host_xmlrpc_port: 9069
odoo_default_country_code: FR
odoo_versions:
- release: 9.0
- release: 10.0
- release: 11.0
- release: 12.0
migration_steps:
- name: 1
release: 9.0
action: update
complete_name: step_01__update__9.0
- name: 2
release: 10.0
action: upgrade
complete_name: step_02__upgrade__10.0
- name: 3
release: 11.0
action: upgrade
complete_name: step_03__upgrade__11.0
- name: 4
release: 12.0
action: upgrade
complete_name: step_04__upgrade__12.0
- name: 5
release: 12.0
action: update
complete_name: step_05__update__12.0

View File

@ -0,0 +1,32 @@
project_name: test-cli
postgres_image_name: postgres:13
postgres_container_name: test-cli-db
odoo_host_xmlrpc_port: 9069
odoo_default_country_code: FR
odoo_versions:
- release: 13.0
- release: 14.0
migration_steps:
- name: 1
release: 13.0
action: update
complete_name: step_01__update__13.0
- name: 2
release: 14.0
action: upgrade
complete_name: step_02__upgrade__14.0
- name: 3
release: 14.0
action: update
complete_name: step_03__update__14.0