-
Notifications
You must be signed in to change notification settings - Fork 5
✨ Add COM StandorteigenschaftenAllgemein #248
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
6 commits
Select commit
Hold shift + click to select a range
a7cfc6e
✨ Add COM StandorteigenschaftenAllgemein
hf-krechan 0e1626d
🩹 Fix datatype for gemeindeeinwohner
hf-krechan 1a29dd0
✅ Add unittest for standorteigenschaftenallgemein
hf-krechan f31f132
🚨 Fix linter warning unused argument kwargs
hf-krechan 0c0a249
🚨 Fix linter warnig
hf-krechan b459f25
Merge branch 'master' into add-com-standorteigenschaftenallgemein
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,54 @@ | ||
| """ | ||
| Contains StandorteigenschaftenAllgemein class | ||
| and corresponding marshmallow schema for de-/serialization | ||
| """ | ||
|
|
||
|
|
||
| import attr | ||
| from marshmallow import fields, post_load | ||
|
|
||
| from bo4e.com.com import COM, COMSchema | ||
|
|
||
| # pylint: disable=too-few-public-methods | ||
| @attr.s(auto_attribs=True, kw_only=True) | ||
| class StandorteigenschaftenAllgemein(COM): | ||
| """ | ||
| Allgemeine Standorteigenschaften | ||
| """ | ||
|
|
||
| # required attributes | ||
| #: Die Postleitzahl des Standorts | ||
| postleitzahl: str = attr.ib(validator=attr.validators.instance_of(str)) | ||
| #: Die Ortsbezeichnung des Standorts | ||
| ort: str = attr.ib(validator=attr.validators.instance_of(str)) | ||
| #: Der Name des Kreises in dem der Standort liegt | ||
| kreisname: str = attr.ib(validator=attr.validators.instance_of(str)) | ||
| #: Der Name der Gemeinde des Standortes | ||
| gemeindename: str = attr.ib(validator=attr.validators.instance_of(str)) | ||
| #: Die standardisierte Kennziffer der Gemeinde | ||
| gemeindekennziffer: str = attr.ib(validator=attr.validators.instance_of(str)) | ||
| #: Anzahl der Einwohner in der Gemeinde | ||
| gemeindeeinwohner: int = attr.ib(validator=attr.validators.instance_of(int)) | ||
| #: Das Bundesland zu dem der Standort gehört | ||
| bundesland: str = attr.ib(validator=attr.validators.instance_of(str)) | ||
|
|
||
|
|
||
| class StandorteigenschaftenAllgemeinSchema(COMSchema): | ||
| """ | ||
| Schema for de-/serialization of StandorteigenschaftenAllgemein. | ||
| """ | ||
|
|
||
| # required attributes | ||
| postleitzahl = fields.Str() | ||
| ort = fields.Str() | ||
| kreisname = fields.Str() | ||
| gemeindename = fields.Str() | ||
| gemeindekennziffer = fields.Str() | ||
| gemeindeeinwohner = fields.Int() | ||
| bundesland = fields.Str() | ||
|
|
||
| # pylint: disable=no-self-use, unused-argument | ||
| @post_load | ||
| def deserialize(self, data, **kwargs) -> StandorteigenschaftenAllgemein: | ||
| """Deserialize JSON to StandorteigenschaftenAllgemein object""" | ||
| return StandorteigenschaftenAllgemein(**data) | ||
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,46 @@ | ||
| import pytest # type:ignore[import] | ||
|
|
||
| from bo4e.com.standorteigenschaftenallgemein import StandorteigenschaftenAllgemein, StandorteigenschaftenAllgemeinSchema | ||
| from tests.serialization_helper import assert_serialization_roundtrip # type:ignore[import] | ||
|
|
||
|
|
||
| class TestStandorteigenschaftenAllgemein: | ||
| @pytest.mark.parametrize( | ||
| "standorteigenschaftenallgemein, expected_json_dict", | ||
| [ | ||
| pytest.param( | ||
| StandorteigenschaftenAllgemein( | ||
| postleitzahl="66646", | ||
| ort="Alsweiler", | ||
| kreisname="St. Wendel", | ||
| gemeindename="Marpingen", | ||
| gemeindekennziffer="10 0 46 112", | ||
| gemeindeeinwohner=9961, | ||
| bundesland="Saarland", | ||
| ), | ||
| { | ||
| "postleitzahl": "66646", | ||
| "ort": "Alsweiler", | ||
| "kreisname": "St. Wendel", | ||
| "gemeindename": "Marpingen", | ||
| "gemeindekennziffer": "10 0 46 112", | ||
| "gemeindeeinwohner": 9961, | ||
| "bundesland": "Saarland", | ||
| }, | ||
| ) | ||
| ], | ||
| ) | ||
| def test_standorteigenschaftenallgemein_serialization_roundtrip( | ||
| self, standorteigenschaftenallgemein: StandorteigenschaftenAllgemein, expected_json_dict: dict | ||
| ): | ||
| """ | ||
| Test de-/serialisation of StandorteigenschaftenAllgemein with minimal attributes. | ||
| """ | ||
| assert_serialization_roundtrip( | ||
| standorteigenschaftenallgemein, StandorteigenschaftenAllgemeinSchema(), expected_json_dict | ||
| ) | ||
|
|
||
| def test_standorteigenschaftenallgemein_missing_required_attributes(self): | ||
| with pytest.raises(TypeError) as excinfo: | ||
| _ = StandorteigenschaftenAllgemein() | ||
| assert "missing 7 required" in str(excinfo.value) |
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.