-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from PeteRager/0.1.9-dev
Message logger fix for multiple connections, sibling data processing
- Loading branch information
Showing
13 changed files
with
358 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -9,5 +9,6 @@ eggs | |
parts | ||
log.txt.log | ||
*.egg-info | ||
*.tmp | ||
lib | ||
lib64 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,25 @@ | ||
{ | ||
"MessageId": 0, | ||
"SenderID": "0000000-0000-0000-0000-000000000002", | ||
"TargetID": "homeassistant", | ||
"MessageType": "PropertyChange", | ||
"Data": { | ||
"siblings": [ | ||
{ | ||
"publisher": { | ||
"publisherName": "lcc" | ||
}, | ||
"id": 0, | ||
"selfIdentifier": "KL21J00001", | ||
"sibling": { | ||
"identifier": "KL21J00002", | ||
"systemName": "\"Bedrooms\"", | ||
"nodePresent": true, | ||
"portNumber": 443, | ||
"groupCountTracker": true, | ||
"ipAddress": "10.0.0.2" | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains 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,42 @@ | ||
{ | ||
"_comment" : "This is not a real messages that was captured, it's purpose is to test error handling", | ||
"MessageId": 0, | ||
"SenderID": "0000000-0000-0000-0000-000000000002", | ||
"TargetID": "homeassistant", | ||
"MessageType": "PropertyChange", | ||
"Data": { | ||
"siblings": [ | ||
{ | ||
"publisher": { | ||
"publisherName": "lcc" | ||
}, | ||
"id": 0, | ||
"selfIdentifier": "KL21J00001", | ||
"sibling": { | ||
"identifier": "KL21J00002", | ||
"systemName": "\"Bedrooms\"", | ||
"nodePresent": true, | ||
"portNumber": 443, | ||
"groupCountTracker": true, | ||
"ipAddress": "10.0.0.2" | ||
} | ||
}, | ||
{ | ||
"publisher": { | ||
"publisherName": "lcc" | ||
}, | ||
"id": 0, | ||
"selfIdentifier": "KL21J00003", | ||
"sibling": { | ||
"identifier": "KL21J00004", | ||
"systemName": "\"Living Room\"", | ||
"nodePresent": true, | ||
"portNumber": 443, | ||
"groupCountTracker": true, | ||
"ipAddress": "10.0.0.3" | ||
} | ||
} | ||
|
||
] | ||
} | ||
} |
This file contains 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,11 @@ | ||
{ | ||
"_comment" : "This is not a real messages that was captured, it's purpose is to test error handling", | ||
"MessageId": 0, | ||
"SenderID": "0000000-0000-0000-0000-000000000002", | ||
"TargetID": "homeassistant", | ||
"MessageType": "PropertyChange", | ||
"Data": { | ||
"siblings": [ | ||
] | ||
} | ||
} |
This file contains 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,53 @@ | ||
import logging | ||
from lennoxs30api.s30api_async import ( | ||
lennox_system, | ||
s30api_async, | ||
) | ||
|
||
from tests.conftest import loadfile | ||
|
||
|
||
def test_api_process_sibling_message(api: s30api_async, caplog): | ||
lsystem: lennox_system = api.getSystems()[1] | ||
assert lsystem.sysId == "0000000-0000-0000-0000-000000000002" | ||
|
||
message = loadfile("sibling.json") | ||
api.processMessage(message) | ||
|
||
assert lsystem.sibling_self_identifier == "KL21J00001" | ||
assert lsystem.sibling_identifier == "KL21J00002" | ||
assert api.metrics.sibling_message_drop == 0 | ||
message = loadfile("mut_sys1_zone1_status.json") | ||
message["SenderId"] = "KL21J00002" | ||
caplog.clear() | ||
api.metrics.reset() | ||
with caplog.at_level(logging.DEBUG): | ||
api.processMessage(message) | ||
assert len(caplog.records) == 1 | ||
assert "KL21J00002" in caplog.messages[0] | ||
assert caplog.records[0].levelname == "WARNING" | ||
assert api.metrics.sibling_message_drop == 1 | ||
assert api.metrics.sender_message_drop == 0 | ||
|
||
api.processMessage(message) | ||
assert len(caplog.records) == 2 | ||
assert "KL21J00002" in caplog.messages[1] | ||
assert caplog.records[1].levelname == "DEBUG" | ||
assert api.metrics.sibling_message_drop == 2 | ||
assert api.metrics.sender_message_drop == 0 | ||
|
||
|
||
def test_api_process_unknown_sender(api: s30api_async, caplog): | ||
lsystem: lennox_system = api.getSystems()[1] | ||
assert lsystem.sysId == "0000000-0000-0000-0000-000000000002" | ||
message = loadfile("mut_sys1_zone1_status.json") | ||
message["SenderId"] = "KL21J00002" | ||
caplog.clear() | ||
api.metrics.reset() | ||
with caplog.at_level(logging.DEBUG): | ||
api.processMessage(message) | ||
assert len(caplog.records) == 1 | ||
assert "KL21J00002" in caplog.messages[0] | ||
assert caplog.records[0].levelname == "ERROR" | ||
assert api.metrics.sibling_message_drop == 0 | ||
assert api.metrics.sender_message_drop == 1 |
Oops, something went wrong.