Skip to content

Commit

Permalink
KDP-1528 refactor instances, collections, and dataqueries
Browse files Browse the repository at this point in the history
  • Loading branch information
rosinaderks committed Oct 9, 2023
1 parent 7cfb79c commit 53070be
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/edr_pydantic/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import List
from typing import Optional

from .data_queries import CollectionDataQueries
from .data_queries import DataQueries
from .extent import Extent
from .link import Link
Expand All @@ -17,7 +16,7 @@ class Collection(EDRBaseModel):
keywords: Optional[List[str]] = None
links: List[Link]
extent: Extent
data_queries: Optional[CollectionDataQueries] = None
data_queries: Optional[DataQueries] = None
# TODO According to req A.13 it should be CRSDetails object
crs: Optional[List[str]] = None
output_formats: Optional[List[str]] = None
Expand All @@ -26,16 +25,16 @@ class Collection(EDRBaseModel):
distanceunits: Optional[List[str]] = None


class CollectionsModel(EDRBaseModel):
class Collections(EDRBaseModel):
links: List[Link]
collections: List[Collection]


# For now, the instance metadata corresponds to the first collection metadata. So they have equal classes
class Instance(Collection):
data_queries: Optional[DataQueries] = None
pass


class InstancesModel(EDRBaseModel):
class Instances(EDRBaseModel):
links: List[Link]
instances: List[Instance]
2 changes: 2 additions & 0 deletions src/edr_pydantic/data_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class DataQueries(EDRBaseModel):
# TODO Difference object/req: item, location?
locations: Optional[EDRQuery] = None
items: Optional[EDRQuery] = None
# TODO ticket maken en maken voor separation
instances: Optional[EDRQuery] = None


class CollectionDataQueries(DataQueries):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from pathlib import Path

import pytest
from edr_pydantic.collections import CollectionsModel
from edr_pydantic.collections import Collections
from pydantic import ValidationError


happy_cases = [
("knmi-example-collection.json", CollectionsModel),
("doc-example-collection.json", CollectionsModel),
("knmi-example-collection.json", Collections),
("doc-example-collection.json", Collections),
]


Expand Down

0 comments on commit 53070be

Please sign in to comment.