Skip to content

Commit

Permalink
Fix unit tests for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
troyraen committed Jan 4, 2025
1 parent 4a3445a commit 6f815da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
25 changes: 17 additions & 8 deletions tests/hats_import/verification/test_run_verification.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
from pathlib import Path

import pandas as pd
import pytest

import hats_import.verification.run_verification as runner
from hats_import.verification.arguments import VerificationArguments

# This directory is common to all bad files expected to be found in the tests.
# Define it using pathlib because it needs to have the correct syntax regardless of OS.
COMMON_DIR = Path("Norder=0") / "Dir=0"


def test_bad_args():
"""Runner should fail with empty or mis-typed arguments"""
Expand Down Expand Up @@ -44,7 +50,10 @@ def test_test_file_sets(small_sky_object_catalog, wrong_files_and_rows_dir, tmp_
verifier = runner.Verifier.from_args(args)
passed = verifier.test_file_sets()
assert not passed, "bad catalog passed"
bad_files = {"Norder=0/Dir=0/Npix=11.extra_file.parquet", "Norder=0/Dir=0/Npix=11.missing_file.parquet"}
bad_files = {
str(COMMON_DIR / "Npix=11.extra_file.parquet"),
str(COMMON_DIR / "Npix=11.missing_file.parquet"),
}
assert bad_files == set(verifier.results_df.bad_files.squeeze()), "bad_files failed"


Expand Down Expand Up @@ -84,9 +93,9 @@ def test_test_num_rows(small_sky_object_catalog, wrong_files_and_rows_dir, tmp_p
assert targets == set(results.target), "wrong targets"

bad_files = {
"Norder=0/Dir=0/Npix=11.extra_file.parquet",
"Norder=0/Dir=0/Npix=11.extra_rows.parquet",
"Norder=0/Dir=0/Npix=11.missing_file.parquet",
str(COMMON_DIR / "Npix=11.extra_file.parquet"),
str(COMMON_DIR / "Npix=11.extra_rows.parquet"),
str(COMMON_DIR / "Npix=11.missing_file.parquet"),
}
_result = results.loc[results.target == "file footers vs _metadata"].squeeze()
assert bad_files == set(_result.bad_files), "wrong bad_files"
Expand Down Expand Up @@ -132,10 +141,10 @@ def test_test_schemas(small_sky_object_catalog, bad_schemas_dir, tmp_path, check
# and files with wrong metadata to fail if check_metadata is true.
result = results.loc[results.target == "file footers vs truth"].squeeze()
expected_bad_files = [
"Norder=0/Dir=0/Npix=11.extra_column.parquet",
"Norder=0/Dir=0/Npix=11.missing_column.parquet",
"Norder=0/Dir=0/Npix=11.wrong_dtypes.parquet",
str(COMMON_DIR / "Npix=11.extra_column.parquet"),
str(COMMON_DIR / "Npix=11.missing_column.parquet"),
str(COMMON_DIR / "Npix=11.wrong_dtypes.parquet"),
]
if check_metadata:
expected_bad_files = expected_bad_files + ["Norder=0/Dir=0/Npix=11.wrong_metadata.parquet"]
expected_bad_files = expected_bad_files + [str(COMMON_DIR / "Npix=11.wrong_metadata.parquet")]
assert set(expected_bad_files) == set(result.bad_files), "wrong bad_files"
13 changes: 0 additions & 13 deletions tests/hats_import/verification/test_verification_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,6 @@
from hats_import.verification.arguments import VerificationArguments


def test_none():
"""No arguments provided. Should error for required args."""
with pytest.raises(TypeError):
VerificationArguments()


def test_empty_required(tmp_path):
"""*Most* required arguments are provided."""
## Input path is missing
with pytest.raises(TypeError, match="input_catalog_path"):
VerificationArguments(output_path=tmp_path)


def test_invalid_paths(tmp_path, small_sky_object_catalog):
"""Required arguments are provided, but paths aren't found."""
## Prove that it works with required args
Expand Down

0 comments on commit 6f815da

Please sign in to comment.