Skip to content

Commit

Permalink
improved for black, isort,... removed unsed validators
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaDaniel committed Oct 9, 2023
1 parent c47bbe6 commit c2cb9f0
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 8 deletions.
60 changes: 60 additions & 0 deletions json_schemas/com/Zeitintervall.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"$defs": {
"Mengeneinheit": {
"description": "Einheit: Messgrößen, die per Messung oder Vorgabe ermittelt werden können.",
"enum": [
"W",
"WH",
"KW",
"KWH",
"KVARH",
"MW",
"MWH",
"STUECK",
"KUBIKMETER",
"SEKUNDE",
"MINUTE",
"STUNDE",
"VIERTEL_STUNDE",
"TAG",
"WOCHE",
"MONAT",
"QUARTAL",
"HALBJAHR",
"JAHR",
"PROZENT"
],
"title": "Mengeneinheit",
"type": "string"
}
},
"additionalProperties": true,
"description": "Abbildung für ein Zeitintervall. Die Abbildung eines Zeitintervalls.\nZ.B. zur Anwendung als Raster in äquidistanten Zeitreihen/Lastgängen, beispielsweise 15 Minuten.\n\n.. raw:: html\n\n <object data=\"../_static/images/bo4e/com/Zeitintervall.svg\" type=\"image/svg+xml\"></object>\n\n.. HINT::\n `Zeitintervall JSON Schema <https://json-schema.app/view/%23?url=https://raw.githubusercontent.com/Hochfrequenz/BO4E-python/main/json_schemas/com/Zeitintervall.json>`_",
"properties": {
"_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": " Id"
},
"wert": {
"title": "Wert",
"type": "integer"
},
"zeiteinheit": {
"$ref": "#/$defs/Mengeneinheit"
}
},
"required": [
"wert",
"zeiteinheit"
],
"title": "Zeitintervall",
"type": "object"
}
1 change: 0 additions & 1 deletion src/bo4e/com/rechnungsposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from bo4e.com.steuerbetrag import Steuerbetrag
from bo4e.enum.bdewartikelnummer import BDEWArtikelnummer
from bo4e.enum.mengeneinheit import Mengeneinheit
from bo4e.validators import check_bis_is_later_than_von


class Rechnungsposition(COM):
Expand Down
1 change: 0 additions & 1 deletion src/bo4e/com/zeitraum.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from bo4e.com.com import COM
from bo4e.enum.mengeneinheit import Mengeneinheit
from bo4e.validators import combinations_of_fields

# pylint: disable=too-few-public-methods

Expand Down
1 change: 0 additions & 1 deletion src/bo4e/com/zeitreihenwert.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Contains Zeitreihenwert class
and corresponding marshmallow schema for de-/serialization
"""
from datetime import datetime
from decimal import Decimal
from typing import Optional

Expand Down
3 changes: 2 additions & 1 deletion tests/test_lastgang.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from _decimal import Decimal
from pydantic import ValidationError

from bo4e.bo.lastgang import Lastgang
Expand Down Expand Up @@ -41,7 +42,7 @@ class TestLastgang:
messlokations_id="DE00056266802AO6G56M11SN51G21M24S",
sparte=Sparte.STROM,
),
zeit_intervall_laenge=Menge(wert="1", einheit=Mengeneinheit.VIERTEL_STUNDE),
zeit_intervall_laenge=Menge(wert=Decimal(1.0), einheit=Mengeneinheit.VIERTEL_STUNDE),
),
),
],
Expand Down
8 changes: 4 additions & 4 deletions tests/test_zeitreihenwert.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ def test_zeitreihenwert_required_and_optional_attributes(self) -> None:
zeitreihenwert_deserialized: Zeitreihenwert = Zeitreihenwert.model_validate_json(json_string)
assert zeitreihenwert_deserialized == zeitreihenwert

assert isinstance( zeitreihenwert_deserialized.wert, Decimal)
assert isinstance( zeitreihenwert_deserialized.status, Messwertstatus)
assert isinstance( zeitreihenwert_deserialized.statuszusatz, Messwertstatuszusatz)
assert isinstance(zeitreihenwert_deserialized.wert, Decimal)
assert isinstance(zeitreihenwert_deserialized.status, Messwertstatus)
assert isinstance(zeitreihenwert_deserialized.statuszusatz, Messwertstatuszusatz)

def test_wrong_datatype(self) -> None:
with pytest.raises(ValidationError) as excinfo:
_ = Zeitreihenwert(wert="helloooo") # type: ignore[arg-type]

assert "wert" in str(excinfo.value)
assert "wert" in str(excinfo.value)

0 comments on commit c2cb9f0

Please sign in to comment.