Skip to content

Commit

Permalink
1.2:
Browse files Browse the repository at this point in the history
- fixed typo
- added py.typed
  • Loading branch information
- committed Oct 11, 2022
1 parent c4b5ff5 commit 912008e
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 30 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include LICENSE
include src/smllib/py.typed
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pre-commit==2.16.0
pytest==6.2.5
pre-commit==2.20.0
pytest==7.1.3
2 changes: 1 addition & 1 deletion src/smllib/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.1'
__version__ = '1.2'
Empty file added src/smllib/py.typed
Empty file.
2 changes: 1 addition & 1 deletion src/smllib/sml/response_get_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SmlGetListResponse(SmlBaseObj):
}

client_id: Optional[str]
sever_id: str
server_id: str
list_name: Optional[str]
act_sensor_time: TIME_HINT
val_list: Tuple[SmlListEntry, ...]
Expand Down
4 changes: 2 additions & 2 deletions tests/builder/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_build_entry_list():
builder = SmlGetListResponseBuilder()

obj = builder.build(data, {SmlListEntry: SmlListEntryBuilder()}) # type: SmlGetListResponse
assert obj.sever_id == 'server'
assert obj.server_id == 'server'
assert obj.val_list[0].obis == '0100010800ff'
assert obj.val_list[0].value == 'val1'
assert obj.val_list[1].obis == '0100010801ff'
Expand All @@ -37,7 +37,7 @@ def build(self, obj: list, classes):
return ret

obj = builder.build(data, {SmlListEntry: PatchedBuilder()}) # type: SmlGetListResponse
assert obj.sever_id == 'server'
assert obj.server_id == 'server'
assert obj.val_list[0].obis == '0100010800ff_patched'
assert obj.val_list[0].value == 'val1'
assert obj.val_list[1].obis == '0100010801ff_patched'
Expand Down
2 changes: 1 addition & 1 deletion tests/sml/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_list_entry():

assert obj.format_msg() == '<SmlGetListResponse>\n' \
' client_id : None\n' \
' sever_id : server\n' \
' server_id : server\n' \
' list_name : None\n' \
' act_sensor_time : None\n' \
' val_list:\n' \
Expand Down
68 changes: 47 additions & 21 deletions tests/test_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,53 @@ def test_frames(frame):
obis.get_value()


def test_frame_only():
data = b'7607000e1ef6d82a620062007263010176010107000e10e4480e0b060606060104c56c97db0101635584007607000e1ef6d82b62' \
b'0062007263070177010b060606060104c56c97db070100620affff7262016510e460887a77078181c78203ff0101010104454d48' \
b'0177070100000009ff010101010b060606060104c56c97db0177070100010800ff640101a201621e52ff56000706507d01770701' \
b'00020800ff640101a201621e52ff5600136473340177070100010801ff0101621e52ff56000706507d0177070100020801ff0101' \
b'621e52ff5600136473340177070100010802ff0101621e52ff5600000000000177070100020802ff0101621e52ff560000000000' \
b'0177070100100700ff0101621b52ff55fffff9140177078181c78205ff017262016510e46088010183026b6b6b6bb6b66b6b6b6b' \
b'09910a958432f7c76ef11e1ba5d13d047051d5b189e1263e62d73058e3f03e219b24804ecac4010101632538007607000e1ef6d8' \
b'2e62006200726302017101639eda00'

f = SmlFrame(a2b_hex(data))
@pytest.mark.parametrize(
'data', (
pytest.param(
b'760505b6436862006200726301017601010501e76bce0b090149534b0004812d55010163696c00760505b643696200620072630'
b'70177010b090149534b0004812d55070100620affff72620165028654d27a77078181c78203ff010101010449534b0177070100'
b'000009ff010101010b090149534b0004812d550177070100010800ff650001018201621e52ff590000000003617c82017707010'
b'0010801ff0101621e52ff590000000003617c820177070100010802ff0101621e52ff5900000000000000000177070100020800'
b'ff0101621e52ff5900000000033b55d50177070100020801ff0101621e52ff5900000000033b55d50177070100020802ff01016'
b'21e52ff5900000000000000000177070100100700ff0101621b520055000000c40177078181c78205ff01010101830255ee18e3'
b'85e7aa763de1b81508f198e40e495f1ef707f779be518456b0f293674b06d0ea4060f11f2b6f6fb5d1c7ae620101016396c6007'
b'60505b6436a6200620072630201710163fd4900',
id='Frame1'
),
pytest.param(
b'7607000e1ef6d82a620062007263010176010107000e10e4480e0b060606060104c56c97db0101635584007607000e1ef6d82b62'
b'0062007263070177010b060606060104c56c97db070100620affff7262016510e460887a77078181c78203ff0101010104454d48'
b'0177070100000009ff010101010b060606060104c56c97db0177070100010800ff640101a201621e52ff56000706507d01770701'
b'00020800ff640101a201621e52ff5600136473340177070100010801ff0101621e52ff56000706507d0177070100020801ff0101'
b'621e52ff5600136473340177070100010802ff0101621e52ff5600000000000177070100020802ff0101621e52ff560000000000'
b'0177070100100700ff0101621b52ff55fffff9140177078181c78205ff017262016510e46088010183026b6b6b6bb6b66b6b6b6b'
b'09910a958432f7c76ef11e1ba5d13d047051d5b189e1263e62d73058e3f03e219b24804ecac4010101632538007607000e1ef6d8'
b'2e62006200726302017101639eda00',
id='Frame2'
),
pytest.param(
b'7605004bf37b620062007263010176010105001951290b0a0149534b0005020de27262016500194f586201631084007605004bf3'
b'7c620062007263070177010b0a0149534b0005020de2070100620affff7262016500194f58757707010060320101010101010449'
b'534b0177070100600100ff010101010b0a0149534b0005020de20177070100010800ff65001c010401621e52ff6500247bc10177'
b'070100020800ff0101621e52ff62000177070100100700ff0101621b520053080d01010163fdc0007605004bf37d620062007263'
b'020171016357f100',
id='Frame3'
),
)
)
def test_frame_only(data):
frame = SmlFrame(a2b_hex(data))

parsed_msgs = f.parse_frame()
for msg in parsed_msgs:
# prints a nice overview over the received values
print(msg.format_msg())
# ensure that parsing always works
for _ in range(3):
sml_messages = frame.parse_frame()
assert len(sml_messages) >= 3, sml_messages
for msg in sml_messages:
msg.format_msg()

obis_values = f.get_obis()
print(obis_values)
obis_values = frame.get_obis()
assert len(obis_values) >= 4, obis_values

parsed_msgs = f.parse_frame()
for msg in parsed_msgs:
# prints a nice overview over the received values
print(msg.format_msg())
for obis in obis_values:
obis.format_msg()
obis.get_value()
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
envlist =
py38
py39
py310
flake

[gh-actions]
python =
3.8: py38, flake
3.9: py39
3.8: py38
3.9: py39, flake
3.10: py310

[testenv]
deps =
Expand Down

0 comments on commit 912008e

Please sign in to comment.