diff --git a/micrant/main_cli.py b/micrant/main_cli.py index 5f3ff77..ab937d7 100644 --- a/micrant/main_cli.py +++ b/micrant/main_cli.py @@ -75,13 +75,13 @@ def set(common_spreadsheet_file=None): @click.option("--print-params", "-pp", is_flag=True, help="Print parameters") def gui(params, print_params): mainapp = micrant_app.MicrAnt() + app_tools.set_parameters_by_path(mainapp.parameters, params) if print_params: import pprint - - pprint.pprint(mainapp.parameters_to_dict()) + pprint.pprint(app_tools.params_and_values(mainapp.parameters)) exit() - for param in params: - mainapp.set_parameter(param[0], value=ast.literal_eval(param[1])) + # for param in params: + # mainapp.set_parameter(param[0], value=ast.literal_eval(param[1])) # mainapp.parameters.param(*param[0].split(";")).setValue(ast.literal_eval(param[1])) mainapp.start_gui() diff --git a/tests/cli_test.py b/tests/cli_test.py index bd843bb..98e1d8a 100644 --- a/tests/cli_test.py +++ b/tests/cli_test.py @@ -40,16 +40,6 @@ def test_cli_print_params(): Add image data to common spreadsheet file. :return: """ - # pth = io3d.datasets.join_path( - # "medical", "orig", "sample_data", "SCP003", "SCP003.ndpi", get_root=True - # ) - # - # logger.debug(f"pth={pth}, exists={Path(pth).exists()}") - # common_xlsx = Path("test_data.xlsx") - # logger.debug(f"expected_pth={common_xlsx}, exists: {common_xlsx.exists()}") - # if common_xlsx.exists(): - # logger.debug(f"Deleting file {common_xlsx} before tests") - # os.remove(common_xlsx) runner = click.testing.CliRunner() # runner.invoke(anwa.main_click.nogui, ["-i", str(pth)]) @@ -58,3 +48,17 @@ def test_cli_print_params(): ["nogui", "-pp", "-p", "Processing;Intensity Normalization", "True", "-p", "Annotation;Upper Threshold", "1.5"], ) assert result.output.find(" 'Annotation;Upper Threshold': 1.5,") > 0 + +def test_cli_print_params(): + """ + Add image data to common spreadsheet file. + :return: + """ + + runner = click.testing.CliRunner() + # runner.invoke(anwa.main_click.nogui, ["-i", str(pth)]) + result = runner.invoke( + micrant.main_cli.run, + ["gui", "-pp", "-p", "Processing;Intensity Normalization", "True", "-p", "Annotation;Upper Threshold", "1.5"], + ) + assert result.output.find(" 'Annotation;Upper Threshold': 1.5,") > 0