-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
137 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 9 additions & 40 deletions
49
tests/hats_import/verification/test_verification_arguments.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,40 @@ | ||
"""Tests of argument validation""" | ||
|
||
import pytest | ||
from hats import read_hats | ||
|
||
from hats_import.verification.arguments import VerificationArguments | ||
|
||
|
||
def test_none(): | ||
"""No arguments provided. Should error for required args.""" | ||
with pytest.raises(ValueError): | ||
with pytest.raises(TypeError): | ||
VerificationArguments() | ||
|
||
|
||
def test_empty_required(tmp_path): | ||
"""*Most* required arguments are provided.""" | ||
## Input path is missing | ||
with pytest.raises(ValueError, match="input_catalog_path"): | ||
VerificationArguments( | ||
output_path=tmp_path, | ||
output_artifact_name="small_sky_object_verification_report", | ||
) | ||
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 | ||
VerificationArguments( | ||
input_catalog_path=small_sky_object_catalog, | ||
output_path=tmp_path, | ||
output_artifact_name="small_sky_object_verification_report", | ||
) | ||
VerificationArguments(input_catalog_path=small_sky_object_catalog, output_path=tmp_path) | ||
|
||
## Input path is invalid catalog | ||
with pytest.raises(ValueError, match="input_catalog_path not a valid catalog"): | ||
VerificationArguments( | ||
input_catalog_path="path", | ||
output_path=f"{tmp_path}/path", | ||
output_artifact_name="small_sky_object_verification_report", | ||
) | ||
|
||
|
||
def test_good_paths(tmp_path, small_sky_object_catalog): | ||
"""Required arguments are provided, and paths are found.""" | ||
tmp_path_str = str(tmp_path) | ||
args = VerificationArguments( | ||
input_catalog_path=small_sky_object_catalog, | ||
output_path=tmp_path, | ||
output_artifact_name="small_sky_object_verification_report", | ||
) | ||
assert args.input_catalog_path == small_sky_object_catalog | ||
assert str(args.output_path) == tmp_path_str | ||
assert str(args.tmp_path).startswith(tmp_path_str) | ||
## Input path is not an existing directory | ||
with pytest.raises(ValueError, match="input_catalog_path must be an existing directory"): | ||
VerificationArguments(input_catalog_path="path", output_path=f"{tmp_path}/path") | ||
|
||
|
||
@pytest.mark.timeout(5) | ||
def test_catalog_object(tmp_path, small_sky_object_catalog): | ||
def test_good_paths(tmp_path, small_sky_object_catalog): | ||
"""Required arguments are provided, and paths are found. | ||
NB: This is currently the last test in alpha-order, and may require additional | ||
time to teardown fixtures.""" | ||
small_sky_catalog_object = read_hats(catalog_path=small_sky_object_catalog) | ||
tmp_path_str = str(tmp_path) | ||
args = VerificationArguments( | ||
input_catalog=small_sky_catalog_object, | ||
output_path=tmp_path, | ||
output_artifact_name="small_sky_object_verification_report", | ||
) | ||
args = VerificationArguments(input_catalog_path=small_sky_object_catalog, output_path=tmp_path) | ||
assert args.input_catalog_path == small_sky_object_catalog | ||
assert str(args.output_path) == tmp_path_str | ||
assert str(args.tmp_path).startswith(tmp_path_str) |