-
Notifications
You must be signed in to change notification settings - Fork 5
Implement BO Standorteigenschaften #300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7f2692c
implement COM StandorteigenschaftenStrom
hf-kklein a99c7b8
Merge branch 'master' into standortseigenschaftenstrom
hf-kklein b9fb201
Merge branch 'master' into standortseigenschaftenstrom
hf-kklein a721ec0
Implement BO Standorteigenschaften
hf-kklein 5e9dbdb
remove unused import
hf-kklein c45815d
Update standorteigenschaften.py
hf-kklein 3283461
Merge branch 'master' into standortseigenschaftenstrom
hf-kklein e569872
remove code
hf-kklein ae703f0
Merge branch 'standortseigenschaftenstrom' into standorteigenschaften
hf-kklein 3321d24
remove unused code
hf-kklein f06648b
Merge remote-tracking branch 'origin/standorteigenschaften' into stan…
hf-kklein 020a561
Merge branch 'master' into standorteigenschaften
hf-kklein 4258d3e
black.
hf-kklein 8d68a5f
Update src/bo4e/bo/standorteigenschaften.py
hf-kklein b209476
Merge branch 'master' into standorteigenschaften
hf-kklein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,57 @@ | ||
| """ | ||
| Contains Standorteigenschaften class | ||
| and corresponding marshmallow schema for de-/serialization | ||
| """ | ||
| from typing import List, Optional | ||
|
|
||
| import attr | ||
| from marshmallow import fields | ||
|
|
||
| from bo4e.bo.geschaeftsobjekt import Geschaeftsobjekt, GeschaeftsobjektSchema | ||
| from bo4e.com.standorteigenschaftenallgemein import StandorteigenschaftenAllgemein, StandorteigenschaftenAllgemeinSchema | ||
| from bo4e.com.standorteigenschaftengas import StandorteigenschaftenGas, StandorteigenschaftenGasSchema | ||
| from bo4e.com.standorteigenschaftenstrom import StandorteigenschaftenStrom, StandorteigenschaftenStromSchema | ||
| from bo4e.enum.botyp import BoTyp | ||
| from bo4e.validators import check_list_length_at_least_one | ||
|
|
||
|
|
||
| # pylint: disable=too-few-public-methods | ||
| @attr.s(auto_attribs=True, kw_only=True) | ||
| class Standorteigenschaften(Geschaeftsobjekt): | ||
| """ | ||
| Modelliert die regionalen und spartenspezifischen Eigenschaften einer gegebenen Adresse. | ||
| """ | ||
|
|
||
| # required attributes | ||
| bo_typ: BoTyp = attr.ib(default=BoTyp.STANDORTEIGENSCHAFTEN) | ||
| #: Allgemeine Eigenschaften | ||
| eigenschaften_allgemein: StandorteigenschaftenAllgemein = attr.ib( | ||
| validator=attr.validators.instance_of(StandorteigenschaftenAllgemein) | ||
| ) | ||
| #: Eigenschaften zur Sparte Strom | ||
| eigenschaften_strom: List[StandorteigenschaftenStrom] = attr.ib( | ||
| validator=attr.validators.deep_iterable( | ||
| member_validator=attr.validators.instance_of(StandorteigenschaftenStrom), | ||
| iterable_validator=check_list_length_at_least_one, | ||
| ) | ||
| ) | ||
| # optional attributes | ||
| #: Eigenschaften zur Sparte Gas | ||
| eigenschaften_gas: Optional[StandorteigenschaftenGas] = attr.ib( | ||
| validator=attr.validators.optional(attr.validators.instance_of(StandorteigenschaftenGas)), default=None | ||
| ) | ||
|
|
||
|
|
||
| class StandorteigenschaftenSchema(GeschaeftsobjektSchema): | ||
| """ | ||
| Schema for de-/serialization of Standorteigenschaften | ||
| """ | ||
|
|
||
| class_name = Standorteigenschaften | ||
| # required attributes | ||
| eigenschaften_allgemein = fields.Nested(StandorteigenschaftenAllgemeinSchema) | ||
|
|
||
| eigenschaften_strom = fields.List(fields.Nested(StandorteigenschaftenStromSchema)) | ||
|
|
||
| # optional attributes | ||
| eigenschaften_gas = fields.Nested(StandorteigenschaftenGasSchema, load_default=None) |
This file contains hidden or 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 hidden or 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,30 @@ | ||
| import pytest # type:ignore[import] | ||
|
|
||
| from bo4e.bo.standorteigenschaften import Standorteigenschaften, StandorteigenschaftenSchema | ||
| from tests.serialization_helper import assert_serialization_roundtrip # type:ignore[import] | ||
| from tests.test_standorteigenschaftenallgemein import example_standorteigenschaften_allgemein # type:ignore[import] | ||
| from tests.test_standorteigenschaftengas import example_standorteigenschaften_gas # type:ignore[import] | ||
| from tests.test_standorteigenschaftenstrom import example_standorteigenschaften_strom # type:ignore[import] | ||
|
|
||
|
|
||
| class TestStandorteigenschaften: | ||
| @pytest.mark.parametrize( | ||
| "standorteigenschaften", | ||
| [ | ||
| pytest.param( | ||
| Standorteigenschaften( | ||
| eigenschaften_allgemein=example_standorteigenschaften_allgemein, | ||
| eigenschaften_strom=[example_standorteigenschaften_strom], | ||
| eigenschaften_gas=example_standorteigenschaften_gas, | ||
| ) | ||
| ), | ||
| ], | ||
| ) | ||
| def test_serialization_roundtrip(self, standorteigenschaften: Standorteigenschaften): | ||
| assert_serialization_roundtrip(standorteigenschaften, StandorteigenschaftenSchema()) | ||
|
|
||
| def test_missing_required_attribute(self): | ||
| with pytest.raises(TypeError) as excinfo: | ||
| _ = Standorteigenschaften() | ||
|
|
||
| assert "missing 2 required" in str(excinfo.value) | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hier