Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.3.0 # Replace by any tag/version: https://github.com/psf/black/tags
rev: 23.1.0 # Replace by any tag/version: https://github.com/psf/black/tags
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile requirements.in
#
Expand Down
1 change: 1 addition & 0 deletions src/bo4e/bo/geschaeftsobjekt.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Geschaeftsobjekt(BaseModel):

# optional attributes
externe_referenzen: Optional[List[ExterneReferenz]] = []

#: Hier können IDs anderer Systeme hinterlegt werden (z.B. eine SAP-GP-Nummer oder eine GUID)
# pylint:disable=duplicate-code
class Config:
Expand Down
2 changes: 2 additions & 0 deletions src/bo4e/com/adresse.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class Adresse(COM):
ort: str

# optional attributes
#: Bezeichnung des Ortsteils; z.B. "Mitte"
ortsteil: Optional[str] = None
#: Bezeichnung der Straße; z.B. "Weserstraße"
strasse: Optional[str] = None
#: Hausnummer inkl. Zusatz; z.B. "3", "4a"
Expand Down
47 changes: 46 additions & 1 deletion tests/test_adresse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pydantic import ValidationError

from bo4e.com.adresse import Adresse
from bo4e.enum import landescode
from bo4e.enum.landescode import Landescode

# import pydantic
Expand Down Expand Up @@ -97,7 +98,6 @@ def test_serialization_only_required_fields(self) -> None:
assert deserialized_address.postleitzahl == "82031"

def test_serialization_only_required_fields_landescode_AT(self) -> None:

address_test_data = Adresse.parse_file(
"./tests/test_data/test_data_adresse/test_data_adresse_only_required_fields.json",
encoding="utf-8",
Expand Down Expand Up @@ -203,3 +203,48 @@ def test_serialization_of_non_german_address(self) -> None:
assert '"AT"' in serialized_address
deserialized_address = Adresse.parse_raw(serialized_address)
assert deserialized_address.landescode == Landescode.AT # type: ignore[attr-defined]

@pytest.mark.parametrize(
"address_json, adresse",
[
pytest.param(
r"""{"postleitzahl": "12345",
"ort": "ISS spacestation",
"strasse": "Milky Way",
"hausnummer": "42",
"landescode": "FR",
"adresszusatz": "to whom it may concern",
"co_ergaenzung": "you will find me",
"ortsteil": "Mitte"}""",
Adresse(
postleitzahl="12345",
ort="ISS spacestation",
strasse="Milky Way",
hausnummer="42",
landescode=Landescode.FR, # type:ignore[attr-defined]
adresszusatz="to whom it may concern",
co_ergaenzung="you will find me",
ortsteil="Mitte",
),
)
],
)
def test_serialization_with_all_possible_fields(self, address_json: str, adresse: Adresse) -> None:
"""
Test serialization with all required and optional attributes
"""

serialized_address = adresse.json(by_alias=True, ensure_ascii=False)

assert "ISS spacestation" in serialized_address
assert "12345" in serialized_address
assert "Milky Way" in serialized_address
assert "42" in serialized_address
assert "FR" in serialized_address
assert "to whom it may concern" in serialized_address
assert "you will find me" in serialized_address
assert "Mitte" in serialized_address

deserialized_address = Adresse.parse_raw(address_json)

assert deserialized_address == adresse
1 change: 1 addition & 0 deletions tests/test_angebotsteil.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class TestAngebotsteil:
"adresszusatz": None,
"postfach": None,
"coErgaenzung": None,
"ortsteil": None,
"landescode": Landescode.DE, # type: ignore[attr-defined]
},
"energierichtung": Energierichtung.EINSP,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_ausschreibungsdetail.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"adresszusatz": None,
"postfach": None,
"coErgaenzung": None,
"ortsteil": None,
},
"rechnungsadresse": {
"landescode": Landescode.DE, # type: ignore[attr-defined]
Expand All @@ -56,6 +57,7 @@
"adresszusatz": None,
"postfach": None,
"coErgaenzung": None,
"ortsteil": None,
},
"netzbetreiber": None,
"netzebeneLieferung": Netzebene.MSP,
Expand Down Expand Up @@ -112,6 +114,7 @@ class TestAusschreibungsdetail:
"ort": "Grünwald",
"strasse": "Nördliche Münchner Straße",
"coErgaenzung": None,
"ortsteil": None,
},
"rechnungsadresse": {
"hausnummer": "27A",
Expand All @@ -122,6 +125,7 @@ class TestAusschreibungsdetail:
"ort": "Grünwald",
"strasse": "Nördliche Münchner Straße",
"coErgaenzung": None,
"ortsteil": None,
},
"zaehlernummer": "1YSK4234092304",
"prognoseJahresarbeit": {"wert": Decimal("2500"), "einheit": Mengeneinheit.KWH},
Expand Down
2 changes: 2 additions & 0 deletions tests/test_buendelvertrag.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class TestBuendelvertrag:
"adresszusatz": None,
"coErgaenzung": None,
"landescode": Landescode.DE, # type:ignore[attr-defined]
"ortsteil": None,
},
"versionstruktur": "2",
"boTyp": BoTyp.GESCHAEFTSPARTNER,
Expand All @@ -95,6 +96,7 @@ class TestBuendelvertrag:
"adresszusatz": None,
"coErgaenzung": None,
"landescode": Landescode.DE, # type:ignore[attr-defined]
"ortsteil": None,
},
"versionstruktur": "2",
"boTyp": BoTyp.GESCHAEFTSPARTNER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"postfach": "31415",
"adresszusatz": "to whom it may concern",
"co_ergaenzung": "you will find me",
"landescode": "FR"
}
"landescode": "FR",
"ortsteil": "Mitte"
}
2 changes: 2 additions & 0 deletions tests/test_vertrag.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class TestVertrag:
"adresszusatz": None,
"coErgaenzung": None,
"landescode": Landescode.DE, # type:ignore[attr-defined]
"ortsteil": None,
},
}
_vertragspartner2_dict: Dict[str, Any] = {
Expand Down Expand Up @@ -118,6 +119,7 @@ class TestVertrag:
"adresszusatz": None,
"coErgaenzung": None,
"landescode": Landescode.DE, # type:ignore[attr-defined]
"ortsteil": None,
},
}
_vertragsteile_dict: List[Dict[str, Any]] = [
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ deps =
{[testenv:type_check]deps}
{[testenv:coverage]deps}
{[testenv:docs]deps}
black==21.5b2
black==23.1.0
# Replace by any tag/version: https://github.com/psf/black/tags
# and change the pre-commit-config.yaml accordingly
isort
Expand Down