Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
delucchi-cmu committed May 23, 2024
1 parent 956febd commit fc5bd4b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/hipscat_import/catalog/test_map_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,27 @@ def test_map_small_sky_part_order1(tmp_path, small_sky_file0):
assert (result == expected).all()


def test_split_pixels_bad_format(blank_data_file, tmp_path, capsys):
"""Test loading the a file with non-default headers"""
alignment = np.full(12, None)
alignment[11] = (0, 11, 131)
with pytest.raises(NotImplementedError):
mr.split_pixels(
input_file=blank_data_file,
file_reader=None,
highest_order=0,
ra_column="ra_mean",
dec_column="dec_mean",
splitting_key="0",
cache_shard_path=tmp_path,
resume_path=tmp_path,
alignment=alignment,
)
captured = capsys.readouterr()
assert "No file reader implemented" in captured.out
os.makedirs(os.path.join(tmp_path, "splitting"))


def test_split_pixels_headers(formats_headers_csv, assert_parquet_file_ids, tmp_path):
"""Test loading the a file with non-default headers"""
os.makedirs(os.path.join(tmp_path, "splitting"))
Expand Down
16 changes: 16 additions & 0 deletions tests/hipscat_import/soap/test_soap_map_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,19 @@ def test_reduce_joins(small_sky_soap_args, soap_intermediate_dir, small_sky_soap
for row_index in range(14)
]
assert ordered_pixels == list(small_sky_soap_maps.keys())


def test_reduce_joins_missing_files(small_sky_soap_args, soap_intermediate_dir, capsys):
"""Use some previously-computed intermediate files to reduce the joined
leaf parquet files into a single parquet file."""
temp_path = os.path.join(small_sky_soap_args.tmp_path, "resume", "intermediate")
shutil.copytree(
soap_intermediate_dir,
temp_path,
)
small_sky_soap_args.tmp_path = temp_path

with pytest.raises(FileNotFoundError):
reduce_joins(small_sky_soap_args, HealpixPixel(0, 11), object_key="0_11")
captured = capsys.readouterr()
assert "No such file or directory" in captured.out

0 comments on commit fc5bd4b

Please sign in to comment.