Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD committed Aug 9, 2024
1 parent a771a5d commit 65c5d15
Showing 1 changed file with 39 additions and 9 deletions.
48 changes: 39 additions & 9 deletions tests/test_dandi_s3_log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,53 @@ def test_parse_dandi_raw_s3_log_example_0(tmpdir: py.path.local):
pandas.testing.assert_frame_equal(left=test_parsed_s3_log, right=expected_parsed_s3_log)


def test_parse_dandi_raw_s3_log_example_0_parallel(tmpdir: py.path.local):
"""
Most basic test of functionality.
def parse_all_dandi_raw_s3_logs_example_0(tmpdir: py.path.local):
tmpdir = pathlib.Path(tmpdir)

If there are failures in the parsing of any lines found in application,
please raise an issue and contribute them to the example log collection.
"""
file_parent = pathlib.Path(__file__).parent
examples_folder_path = file_parent / "examples" / "ordered_example_0"
expected_parsed_s3_log_folder_path = examples_folder_path / "expected_output"

test_parsed_s3_log_folder_path = tmpdir / "parsed_example_0"
dandi_s3_log_parser.parse_all_dandi_raw_s3_logs(
base_raw_s3_log_folder_path=examples_folder_path,
parsed_s3_log_folder_path=test_parsed_s3_log_folder_path,
)
test_output_file_paths = list(test_parsed_s3_log_folder_path.iterdir())

number_of_output_files = len(test_output_file_paths)
assert number_of_output_files != 0, f"Test expected_output folder ({test_parsed_s3_log_folder_path}) is empty!"

# Increment this over time as more examples are added
expected_number_of_output_files = 2
assert (
number_of_output_files == expected_number_of_output_files
), f"The number of asset files ({number_of_output_files}) does not match expectation!"

expected_asset_ids = [file_path.stem for file_path in expected_parsed_s3_log_folder_path.iterdir()]
for test_parsed_s3_log_file_path in test_output_file_paths:
assert (
test_parsed_s3_log_file_path.stem in expected_asset_ids
), f"Asset ID {test_parsed_s3_log_file_path.stem} not found in expected asset IDs!"

test_parsed_s3_log = pandas.read_table(filepath_or_buffer=test_parsed_s3_log_file_path, index_col=0)
expected_parsed_s3_log_file_path = (
expected_parsed_s3_log_folder_path / f"{test_parsed_s3_log_file_path.stem}.tsv"
)
expected_parsed_s3_log = pandas.read_table(filepath_or_buffer=expected_parsed_s3_log_file_path, index_col=0)
pandas.testing.assert_frame_equal(left=test_parsed_s3_log, right=expected_parsed_s3_log)


def parse_all_dandi_raw_s3_logs_example_0_parallel(tmpdir: py.path.local):
tmpdir = pathlib.Path(tmpdir)

file_parent = pathlib.Path(__file__).parent
examples_folder_path = file_parent / "examples" / "ordered_example_0"
example_raw_s3_log_file_path = examples_folder_path / "example_dandi_s3_log.log"
expected_parsed_s3_log_folder_path = examples_folder_path / "expected_output"

test_parsed_s3_log_folder_path = tmpdir / "parsed_example_0"
dandi_s3_log_parser.parse_dandi_raw_s3_log(
raw_s3_log_file_path=example_raw_s3_log_file_path,
dandi_s3_log_parser.parse_all_dandi_raw_s3_logs(
base_raw_s3_log_folder_path=examples_folder_path,
parsed_s3_log_folder_path=test_parsed_s3_log_folder_path,
number_of_jobs=2,
)
Expand Down

0 comments on commit 65c5d15

Please sign in to comment.