From 39f95209627cbfc8a493a36ad58850c5c70a3fc6 Mon Sep 17 00:00:00 2001 From: itellaetxe Date: Mon, 4 Dec 2023 17:21:10 +0100 Subject: [PATCH] [TST] Fixed test code --- tests/test_ageml/test_ui.py | 50 ++-------------------------------- tests/test_ageml/test_utils.py | 2 -- 2 files changed, 2 insertions(+), 50 deletions(-) diff --git a/tests/test_ageml/test_ui.py b/tests/test_ageml/test_ui.py index ab399d5..d85ce51 100644 --- a/tests/test_ageml/test_ui.py +++ b/tests/test_ageml/test_ui.py @@ -413,52 +413,6 @@ def test_run_clinical(dummy_interface, ages, clinical): assert os.path.exists(log_path) -def test_run_lifestyle(dummy_interface, ages, factors): - # Run the lifestyle pipeline - ages_path = create_csv(ages, dummy_interface.dir_path) - factors_path = create_csv(factors, dummy_interface.dir_path) - dummy_interface.args.ages = ages_path - dummy_interface.args.factors = factors_path - dummy_interface.run_lifestyle() - - # Check for the existence of the output directory - assert os.path.exists(dummy_interface.dir_path) - - # Check for the existence of the output figures - figs = ["factors_vs_deltas"] - svg_paths = [ - os.path.join(dummy_interface.dir_path, f"figures/{fig}.svg") for fig in figs - ] - assert all([os.path.exists(svg_path) for svg_path in svg_paths]) - - # Check for the existence of the log - log_path = os.path.join(dummy_interface.dir_path, "log.txt") - assert os.path.exists(log_path) - - -def test_run_clinical(dummy_interface, ages, clinical): - # Run the clinical pipeline - ages_path = create_csv(ages, dummy_interface.dir_path) - clinical_path = create_csv(clinical, dummy_interface.dir_path) - dummy_interface.args.ages = ages_path - dummy_interface.args.clinical = clinical_path - dummy_interface.run_clinical() - - # Check for the existence of the output directory - assert os.path.exists(dummy_interface.dir_path) - - # Check for the existence of the output figures - figs = ["age_distribution_clinical_groups", "clinical_groups_box_plot"] - svg_paths = [ - os.path.join(dummy_interface.dir_path, f"figures/{fig}.svg") for fig in figs - ] - assert all([os.path.exists(svg_path) for svg_path in svg_paths]) - - # Check for the existence of the log - log_path = os.path.join(dummy_interface.dir_path, "log.txt") - assert os.path.exists(log_path) - - def test_run_classification(dummy_interface, ages, clinical): # Run the classification pipeline ages_path = create_csv(ages, dummy_interface.dir_path) @@ -806,10 +760,10 @@ def test_run_command_interactiveCLI(dummy_cli): # Test no input or mutiple arguments dummy_cli.line = "r" error = dummy_cli.run_command() - assert error == "Must provide one argument only." + assert error == "Must provide at least one argument." dummy_cli.line = "r type1 type1" error = dummy_cli.run_command() - assert error == "Must provide one argument only." + assert error == "Choose a valid run type: age, lifestyle, clinical, classification" # Test passing invalid run type dummy_cli.line = "r type1" diff --git a/tests/test_ageml/test_utils.py b/tests/test_ageml/test_utils.py index da34618..c65a78c 100644 --- a/tests/test_ageml/test_utils.py +++ b/tests/test_ageml/test_utils.py @@ -76,8 +76,6 @@ def test_insert_newlines_zerospacing(): def test_feature_extractor(): - import pandas as pd - df = pd.DataFrame({"age": [1, 2, 3], "feature1": [4, 5, 6], "feature2": [7, 8, 9]}) X, y, feature_names = utils.feature_extractor(df) assert X.shape == (3, 2)