-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KDP-1528 enable publish ci, add initial test file
- Loading branch information
1 parent
141ece6
commit 99a9425
Showing
3 changed files
with
65 additions
and
138 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
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,5 +1,5 @@ | ||
[project] | ||
name = "edr-pydantic-classes" | ||
name = "edr-pydantic" | ||
description = "The Pydantic models for CoverageJSON" | ||
readme = "README.md" | ||
requires-python = ">=3.8" | ||
|
@@ -8,45 +8,44 @@ authors = [ | |
{name = "KNMI Data Platform Team", email = "[email protected]"}, | ||
] | ||
keywords = ["EDR", "Pydantic"] | ||
#classifiers = [ | ||
# "Intended Audience :: Information Technology", | ||
# "Intended Audience :: Science/Research", | ||
classifiers = [ | ||
"Intended Audience :: Information Technology", | ||
"Intended Audience :: Science/Research", | ||
# "License :: OSI Approved :: Apache Software License", | ||
# "Programming Language :: Python :: 3.8", | ||
# "Programming Language :: Python :: 3.9", | ||
# "Programming Language :: Python :: 3.10", | ||
# "Programming Language :: Python :: 3.11", | ||
# "Topic :: Scientific/Engineering :: GIS", | ||
# "Typing :: Typed", | ||
#] | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Topic :: Scientific/Engineering :: GIS", | ||
"Typing :: Typed", | ||
] | ||
version = "0.1.0" | ||
dependencies = ["pydantic>=2.3,<3", "covjson-pydantic~=0.2.0", "python-dateutil"] | ||
dependencies = ["pydantic>=2.3,<3", "covjson-pydantic~=0.2.0"] | ||
|
||
[project.optional-dependencies] | ||
test = ["pytest", "pytest-cov"] | ||
dev = ["pre-commit"] | ||
|
||
[project.urls] | ||
#Source = "https://github.com/knmi/covjson-pydantic" | ||
Source = "https://github.com/rosinaderks/pypi-edr-github-test" | ||
Source = "https://github.com/knmi/edr-pydantic" | ||
|
||
[build-system] | ||
requires = ["flit>=3.2,<4"] | ||
build-backend = "flit_core.buildapi" | ||
|
||
[tool.flit.module] | ||
name = "edr-pydantic" | ||
|
||
[tool.flit.sdist] | ||
exclude = [ | ||
"test/", | ||
".github/", | ||
] | ||
|
||
[tool.mypy] | ||
plugins = [ | ||
"pydantic.mypy" | ||
] | ||
|
||
#[build-system] | ||
#requires = ["flit>=3.2,<4"] | ||
#build-backend = "flit_core.buildapi" | ||
# | ||
#[tool.flit.module] | ||
#name = "edr-pydantic-classes" | ||
# | ||
#[tool.flit.sdist] | ||
#exclude = [ | ||
# "test/", | ||
# ".github/", | ||
#] | ||
# | ||
#[tool.mypy] | ||
#plugins = [ | ||
# "pydantic.mypy" | ||
#] | ||
# | ||
#[tool.pydantic-mypy] | ||
#warn_untyped_fields = true | ||
[tool.pydantic-mypy] | ||
warn_untyped_fields = true |
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,73 +0,0 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
import pytest | ||
from covjson_pydantic.coverage import Coverage | ||
from covjson_pydantic.coverage import CoverageCollection | ||
from covjson_pydantic.domain import Axes | ||
from covjson_pydantic.domain import Domain | ||
from covjson_pydantic.ndarray import NdArray | ||
from covjson_pydantic.ndarray import TiledNdArray | ||
from covjson_pydantic.parameter import Parameter | ||
from covjson_pydantic.parameter import ParameterGroup | ||
from covjson_pydantic.reference_system import ReferenceSystem | ||
from pydantic import ValidationError | ||
|
||
|
||
happy_cases = [ | ||
("spec-axes.json", Axes), | ||
("coverage-json.json", Coverage), | ||
("doc-example-coverage.json", Coverage), | ||
("spec-vertical-profile-coverage.json", Coverage), | ||
("doc-example-coverage-collection.json", CoverageCollection), | ||
("grid-domain.json", Domain), | ||
("point-series-domain-custom.json", Domain), | ||
("spec-domain-grid.json", Domain), | ||
("spec-domain-vertical-profile.json", Domain), | ||
("spec-domain-point-series.json", Domain), | ||
("spec-domain-point.json", Domain), | ||
("spec-domain-multipoint-series.json", Domain), | ||
("spec-domain-multipoint.json", Domain), | ||
("ndarray-float.json", NdArray), | ||
("spec-ndarray.json", NdArray), | ||
("spec-tiled-ndarray.json", TiledNdArray), | ||
("continuous-data-parameter.json", Parameter), | ||
("categorical-data-parameter.json", Parameter), | ||
("spec-parametergroup.json", ParameterGroup), | ||
("spec-reference-system-identifierrs.json", ReferenceSystem), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("file_name, object_type", happy_cases) | ||
def test_happy_cases(file_name, object_type): | ||
file = Path(__file__).parent.resolve() / "test_data" / file_name | ||
# Put JSON in default unindented format | ||
with open(file, "r") as f: | ||
data = json.load(f) | ||
json_string = json.dumps(data, separators=(",", ":")) | ||
|
||
# Round-trip | ||
assert object_type.model_validate_json(json_string).model_dump_json(exclude_none=True) == json_string | ||
|
||
|
||
error_cases = [ | ||
("grid-domain-no-y.json", Domain, r"A 'Grid' must have a 'y'-axis"), | ||
( | ||
"point-series-domain-more-z.json", | ||
Domain, | ||
r"If provided, the 'values' field of the 'z'-axis of a 'PointSeries' domain must contain a single value.", | ||
), | ||
("point-series-domain-no-t.json", Domain, r"A 'PointSeries' must have a 't'-axis."), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("file_name, object_type, error_message", error_cases) | ||
def test_error_cases(file_name, object_type, error_message): | ||
file = Path(__file__).parent.resolve() / "test_data" / file_name | ||
# Put JSON in default unindented format | ||
with open(file, "r") as f: | ||
data = json.load(f) | ||
json_string = json.dumps(data, separators=(",", ":")) | ||
|
||
with pytest.raises(ValidationError, match=error_message): | ||
object_type.model_validate_json(json_string) | ||