diff --git a/wodoo/lib_composer.py b/wodoo/lib_composer.py index 1d500124..c1dbd34c 100644 --- a/wodoo/lib_composer.py +++ b/wodoo/lib_composer.py @@ -289,6 +289,9 @@ def internal_reload( _execute_after_reload(config) + # update a possible robot file also + Commands.invoke(ctx, 'robot:make-var-file') + if float(ODOO_VERSION) >= 17.0: if any(config.ODOO_PYTHON_VERSION.startswith(x) for x in ['3.9.', '3.8.', '3.7.']): abort("Invalid python version - needs at least 3.10") diff --git a/wodoo/lib_robot.py b/wodoo/lib_robot.py index d6e3ef7e..38b111e8 100644 --- a/wodoo/lib_robot.py +++ b/wodoo/lib_robot.py @@ -590,3 +590,30 @@ def start_cobot(ctx, config): click.secho(f"Access cobot at: ") click.secho(f"\n{config.EXTERNAL_DOMAIN}:{config.PROXY_PORT}/cobot\n\n", fg="green", bold=True) + + +@robot.command(help="Creates .robot-vars") +@click.option("-P", "--userpassword", required=False) +@pass_config +@click.pass_context +def make_variable_file(ctx, config, userpassword=None): + host = os.getenv("ROBO_ODOO_HOST") or config.EXTERNAL_DOMAIN + url = f"http://{host}:{config.PROXY_PORT}" + from .odoo_config import customs_dir + path = customs_dir() / ".robot-vars" + if not path.exists(): + path.write_text("{}") + data = json.loads(path.read_text()) + data.setdefault("TOKEN", f'manualrun-{customs_dir().name}') + if userpassword: + data['ODOO_PASSWORD'] = userpassword + data['ODOO_URL'] = url + data['ODOO_USER'] = 'admin' + data['ODOO_DB'] = config.DBNAME + data['ODOO_VERSION'] = str(current_version()) + data['TEST_RUN_INDEX'] = 0 + data["TEST_DIR"] = str(customs_dir() / 'robot-output') + Path(data["TEST_DIR"]).mkdir(exist_ok=True) + path.write_text(json.dumps(data, indent=4)) + +Commands.register(make_variable_file, 'robot:make-var-file') \ No newline at end of file diff --git a/wodoo/lib_turnintodev.py b/wodoo/lib_turnintodev.py index d909009a..c9557deb 100644 --- a/wodoo/lib_turnintodev.py +++ b/wodoo/lib_turnintodev.py @@ -44,6 +44,9 @@ def set_password_all_users(config, ctx, password, default): sql = f"update res_users set password_crypt=password" _execute_sql(conn, sql) + # update a possible robot file also + Commands.invoke(ctx, 'robot:make-var-file', userpassword=password) + @turn_into_dev.command() @click.argument("password")