Skip to content

Commit

Permalink
Merge pull request #110 from dknowles2/model-name
Browse files Browse the repository at this point in the history
Handle model name not being present
  • Loading branch information
dknowles2 committed Dec 31, 2023
2 parents e745209 + 3122154 commit 44cf359
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyschlage/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def from_json(cls, auth: Auth, json: dict) -> Lock:
_auth=auth,
device_id=json["deviceId"],
name=json["name"],
model_name=json["modelName"],
model_name=json.get("modelName", ""),
device_type=json["devicetypeId"],
connected=json.get("connected", False),
battery_level=attributes.get("batteryLevel"),
Expand Down
7 changes: 7 additions & 0 deletions tests/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ def test_from_json_wifi_lock_unavailable(
assert lock.is_locked is None
assert lock.is_jammed is None

def test_from_json_no_model_name(
self, mock_auth: mock.Mock, lock_json: dict[Any, Any]
) -> None:
lock_json.pop("modelName", None)
lock = Lock.from_json(mock_auth, lock_json)
assert lock.model_name == ""

def test_diagnostics(self, mock_auth: mock.Mock, lock_json: dict) -> None:
lock = Lock.from_json(mock_auth, lock_json)
want = {
Expand Down

0 comments on commit 44cf359

Please sign in to comment.