Skip to content

Commit 9f9494e

Browse files
feat(schema): add optional taxonomy_category field to ModelSchema and implement corresponding unit test for YAML parsing
1 parent 32a3747 commit 9f9494e

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/gems/model/parsing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class ExtraOutputSchema(ModifiedBaseModel):
8787

8888
class ModelSchema(ModifiedBaseModel):
8989
id: str
90+
taxonomy_category: Optional[str] = None # # Optional or mandatory,open question ?
9091
parameters: List[ParameterSchema] = Field(default_factory=list)
9192
variables: List[VariableSchema] = Field(default_factory=list)
9293
ports: List[ModelPortSchema] = Field(default_factory=list)

tests/unittests/lib_parsing/test_lib_parsing.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,22 @@ def test_binary_variable_parsing() -> None:
137137
assert on_off.data_type == ValueType.BINARY
138138

139139

140+
def test_model_taxonomy_category_parses() -> None:
141+
yaml_content = """
142+
library:
143+
id: taxo_lib
144+
models:
145+
- id: bus
146+
taxonomy-category: balance
147+
parameters:
148+
- id: v_nom
149+
time-dependent: false
150+
scenario-dependent: false
151+
"""
152+
input_lib = parse_yaml_library(io.StringIO(yaml_content))
153+
assert input_lib.models[0].taxonomy_category == "balance"
154+
155+
140156
def test_library_error_parsing(libs_dir: Path) -> None:
141157
lib_file = libs_dir / "model_port_definition_ko.yml"
142158

0 commit comments

Comments
 (0)