EOX GitLab Instance

Skip to content
Snippets Groups Projects
Commit e6d9fdf8 authored by Bernhard Mallinger's avatar Bernhard Mallinger
Browse files

Use collection name as default product type name

parent fb4a515a
No related branches found
No related tags found
1 merge request!7values simplification tool
......@@ -22,6 +22,20 @@ class ConfigChange(BaseModel):
product_types: list[ProductType]
preprocessing_config: str | None = None
@classmethod
def model_validate(
cls,
obj: dict,
**kwargs,
):
# set default product type name
for product_type in obj.get("product_types", []):
if not product_type.get("name"):
product_type["name"] = obj.get("collection")
return super().model_validate(obj, **kwargs)
@click.command()
@click.argument("config-change-file", type=click.File("r"))
@click.argument(
......
......@@ -73,3 +73,14 @@ def test_change_2(change_file):
assert values == yaml.safe_load(
Path("./update_values/test-values/viewserver2/output-values.yaml").open()
)
def test_collection_name_is_default_product_type_name():
config_change = ConfigChange.model_validate(
{
"stack": 1,
"collection": "yeah",
"product_types": [{"coverage_type": "RGB"}],
}
)
assert config_change.collection == config_change.product_types[0].name
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment