Skip to content

Commit

Permalink
Add tests for set_datatype
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulVanSchayck committed Nov 14, 2024
1 parent 4fffc8b commit 2ae9ec5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from covjson_pydantic.coverage import CoverageCollection
from covjson_pydantic.domain import Axes
from covjson_pydantic.domain import Domain
from covjson_pydantic.ndarray import DataType
from covjson_pydantic.ndarray import NdArray
from covjson_pydantic.ndarray import TiledNdArray
from covjson_pydantic.parameter import Parameter
Expand Down Expand Up @@ -86,3 +87,12 @@ def test_error_cases(file_name, object_type, error_message):

with pytest.raises(ValidationError, match=error_message):
object_type.model_validate_json(json_string)


def test_ndarray_set_datetype():
nd = NdArray[float](axisNames=["x", "y", "t"], shape=[1, 1, 1], values=[42.0])
assert nd.dataType == DataType.float
nd = NdArray[int](axisNames=["x", "y", "t"], shape=[1, 1, 1], values=[42])
assert nd.dataType == DataType.int
nd = NdArray[str](axisNames=["x", "y", "t"], shape=[1, 1, 1], values=["foo"])
assert nd.dataType == DataType.str

0 comments on commit 2ae9ec5

Please sign in to comment.