-
Notifications
You must be signed in to change notification settings - Fork 5
Implement BO PreisblattKonzessionsabgabe #326
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
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,35 @@ | ||
| """ | ||
| Contains PreisblattKonzessionsabgabe class and corresponding marshmallow schema for de-/serialization | ||
| """ | ||
|
|
||
| import attr | ||
| from marshmallow_enum import EnumField # type:ignore[import] | ||
|
|
||
| from bo4e.bo.preisblatt import Preisblatt, PreisblattSchema | ||
| from bo4e.enum.botyp import BoTyp | ||
| from bo4e.enum.kundengruppeka import KundengruppeKA | ||
|
|
||
|
|
||
| # pylint: disable=too-few-public-methods | ||
| @attr.s(auto_attribs=True, kw_only=True) | ||
| class PreisblattKonzessionsabgabe(Preisblatt): | ||
| """ | ||
| Die Variante des Preisblattmodells zur Abbildung von allgemeinen Abgaben | ||
| """ | ||
|
|
||
| bo_typ: BoTyp = attr.ib(default=BoTyp.PREISBLATTKONZESSIONSABGABE) | ||
| # required attributes (additional to those of Preisblatt) | ||
| #: Kundegruppe anhand derer die Höhe der Konzessionabgabe festgelegt ist | ||
| kundengruppe_k_a: KundengruppeKA = attr.ib(validator=attr.validators.instance_of(KundengruppeKA)) | ||
|
|
||
| # there are no optional attributes (additionally to those of Preisblatt) | ||
|
|
||
|
|
||
| class PreisblattKonzessionsabgabeSchema(PreisblattSchema): | ||
| """ | ||
| Schema for de-/serialization of PreisblattKonzessionsabgabe | ||
| """ | ||
|
|
||
| class_name = PreisblattKonzessionsabgabe # type:ignore[assignment] | ||
| # required attributes | ||
| kundengruppe_k_a = EnumField(KundengruppeKA, data_key="kundengruppeKA") | ||
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,39 @@ | ||
| import pytest # type:ignore[import] | ||
|
|
||
| from bo4e.bo.preisblattkonzessionsabgabe import PreisblattKonzessionsabgabe, PreisblattKonzessionsabgabeSchema | ||
| from bo4e.enum.kundengruppeka import KundengruppeKA | ||
| from bo4e.enum.preisstatus import Preisstatus | ||
| from bo4e.enum.sparte import Sparte | ||
| from tests.serialization_helper import assert_serialization_roundtrip # type:ignore[import] | ||
| from tests.test_marktteilnehmer import example_marktteilnehmer # type:ignore[import] | ||
| from tests.test_preisposition import example_preisposition # type:ignore[import] | ||
| from tests.test_zeitraum import example_zeitraum # type:ignore[import] | ||
|
|
||
|
|
||
| class TestPreisblatt: | ||
| @pytest.mark.parametrize( | ||
| "preisblatt_ka", | ||
| [ | ||
| pytest.param( | ||
| PreisblattKonzessionsabgabe( | ||
| bezeichnung="foo", | ||
| sparte=Sparte.STROM, | ||
| preisstatus=Preisstatus.ENDGUELTIG, | ||
| preispositionen=[example_preisposition], | ||
| gueltigkeit=example_zeitraum, | ||
| herausgeber=example_marktteilnehmer, | ||
| kundengruppe_k_a=KundengruppeKA.G_SONDERKUNDE, | ||
| ) | ||
| ), | ||
| ], | ||
| ) | ||
| def test_serialization_roundtrip(self, preisblatt_ka: PreisblattKonzessionsabgabe): | ||
| """ | ||
| Test de-/serialisation | ||
| """ | ||
| assert_serialization_roundtrip(preisblatt_ka, PreisblattKonzessionsabgabeSchema()) | ||
|
|
||
| def test_missing_required_attribute(self): | ||
| with pytest.raises(TypeError) as excinfo: | ||
| _ = PreisblattKonzessionsabgabe() | ||
| assert "missing 6 required" in str(excinfo.value) # 5 from preisblatt + 1 from preisblatt konzessionsabgabe |
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.
Is this a new approach how to deserialize into the right class?
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.
it's not new, just new born ;)
yep, but I didn't manage to override it so that mypy accepts it too.