Skip to content

Commit

Permalink
add unit tests for input and output path validation functions
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfromearth committed Nov 19, 2024
1 parent 9356d78 commit 5f906c9
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/unit/test_file_ops.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from pathlib import Path

from concatenator.file_ops import add_label_to_path
import pytest

from concatenator.file_ops import add_label_to_path, validate_input_path, validate_output_path

from .. import data_for_tests_dir


def test_add_label_to_path():
Expand All @@ -10,3 +14,27 @@ def test_add_label_to_path():
new_path = str((this_module_dir / "tests_file_new-suffix.nc").resolve())

assert add_label_to_path(origin_path, label="_new-suffix") == new_path


def test_validate_bad_output_paths():
path_to_file_that_exists = str(
data_for_tests_dir / "unit-test-data" / "TEMPO_NO2_L2_V03_20240328T154353Z_S008G01.nc4"
)

with pytest.raises(FileExistsError):
validate_output_path(path_to_file_that_exists, overwrite=False)

with pytest.raises(TypeError):
validate_output_path(str(data_for_tests_dir), overwrite=False)


def test_validate_bad_non_existent_input_path():
path_to_file_that_does_not_exist = str(
data_for_tests_dir / "unit-test-data" / "non-existent.nc4"
)

with pytest.raises(TypeError):
validate_input_path([path_to_file_that_does_not_exist])

with pytest.raises(TypeError):
validate_input_path([])

0 comments on commit 5f906c9

Please sign in to comment.