Fix testing issues

This commit is contained in:
mbsantiago 2025-06-23 19:08:55 +01:00
parent 8253b5bdc4
commit b5b4229990
2 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,5 @@
from pathlib import Path from pathlib import Path
from typing import List, Tuple from typing import List, Optional, Tuple
import numpy as np import numpy as np
import pytest import pytest
@ -25,6 +25,7 @@ def dummy_geometry_builder():
def _builder( def _builder(
position: Tuple[float, float], position: Tuple[float, float],
dimensions: xr.DataArray, dimensions: xr.DataArray,
class_name: Optional[str] = None,
) -> data.BoundingBox: ) -> data.BoundingBox:
time, freq = position time, freq = position
width = dimensions.sel(dimension="width").item() width = dimensions.sel(dimension="width").item()
@ -106,7 +107,7 @@ def sample_detection_dataset() -> xr.Dataset:
scores_data, scores_data,
coords=detection_coords, coords=detection_coords,
dims=["detection"], dims=["detection"],
name="score", name="scores",
) )
dimensions_data = np.array([[7.0, 16.0], [3.0, 12.0]], dtype=np.float32) dimensions_data = np.array([[7.0, 16.0], [3.0, 12.0]], dtype=np.float32)
@ -140,7 +141,7 @@ def sample_detection_dataset() -> xr.Dataset:
ds = xr.Dataset( ds = xr.Dataset(
{ {
"score": scores, "scores": scores,
"dimensions": dimensions, "dimensions": dimensions,
"classes": classes, "classes": classes,
"features": features, "features": features,

View File

@ -109,6 +109,7 @@ def test_get_tag_from_info_key_not_found():
def test_load_terms_from_config(tmp_path): def test_load_terms_from_config(tmp_path):
term_registry = TermRegistry()
config_data = { config_data = {
"terms": [ "terms": [
{ {
@ -127,7 +128,10 @@ def test_load_terms_from_config(tmp_path):
with open(config_file, "w") as f: with open(config_file, "w") as f:
yaml.dump(config_data, f) yaml.dump(config_data, f)
loaded_terms = load_terms_from_config(config_file) loaded_terms = load_terms_from_config(
config_file,
term_registry=term_registry,
)
assert "species" in loaded_terms assert "species" in loaded_terms
assert "my_custom_term" in loaded_terms assert "my_custom_term" in loaded_terms
assert loaded_terms["species"].name == "dwc:scientificName" assert loaded_terms["species"].name == "dwc:scientificName"