Skip to content

Commit

Permalink
[TST] Fixed test code
Browse files Browse the repository at this point in the history
  • Loading branch information
itellaetxe committed Dec 4, 2023
1 parent 148bbba commit 39f9520
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 50 deletions.
50 changes: 2 additions & 48 deletions tests/test_ageml/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions tests/test_ageml/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 39f9520

Please sign in to comment.