-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure emission names are unique
Refs: ECALC-896
- Loading branch information
Showing
7 changed files
with
39 additions
and
154 deletions.
There are no files selected for viewing
42 changes: 0 additions & 42 deletions
42
src/libecalc/examples/simple/model_duplicate_emissions_in_fuel.yaml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
22 changes: 22 additions & 0 deletions
22
...s/libecalc/presentation/yaml/yaml_types/models/fuel_type/test_duplicate_emission_names.py
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pytest | ||
from inline_snapshot import snapshot | ||
from pydantic import ValidationError | ||
|
||
from libecalc.testing.yaml_builder import YamlEmissionBuilder, YamlFuelTypeBuilder | ||
|
||
|
||
@pytest.mark.snapshot | ||
@pytest.mark.inlinesnapshot | ||
def test_duplicate_emission_names(): | ||
with pytest.raises(ValidationError) as exc_info: | ||
YamlFuelTypeBuilder().with_test_data().with_emissions( | ||
[ | ||
YamlEmissionBuilder().with_test_data().with_name("co2").validate(), | ||
YamlEmissionBuilder().with_test_data().with_name("co2").validate(), | ||
] | ||
).validate() | ||
|
||
errors = exc_info.value.errors() | ||
assert len(errors) == 1 | ||
|
||
assert errors[0]["msg"] == snapshot("Value error, EMISSIONS names must be unique. Duplicated names are: co2") |