Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: add support for pin lock activities #189

Merged
merged 1 commit into from
Oct 3, 2024
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
14 changes: 14 additions & 0 deletions tests/fixtures/pin_lock_activity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "e05b1c22-71d1-44b8-8a4c-e729174a8972",
"timestamp": 1665378377000,
"icon": "https://d33mytkkohwnk6.cloudfront.net/app/ActivityFeedIcons/pin_lock@3x.png",
"action": "pin_lock",
"deviceID": "3ED27C5DB830439CAA4F381DC8F16444",
"deviceType": "lock",
"user": {
"UserID": "xxxsasdd-230b-4c6a-8a5c-155043492f3b",
"FirstName": "Sample",
"LastName": "Person"
},
"title": "<b>Sample Person</b> locked <b>Front Door</b> with entry code"
}
20 changes: 20 additions & 0 deletions tests/test_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
ACTION_LOCK_MANUAL_UNLOCK,
ACTION_LOCK_ONETOUCHLOCK,
ACTION_LOCK_ONETOUCHLOCK_2,
ACTION_LOCK_PIN_LOCK,
ACTION_LOCK_PIN_UNLATCH,
ACTION_LOCK_PIN_UNLOCK,
ACTION_LOCK_REMOTE_LOCK,
Expand Down Expand Up @@ -139,6 +140,7 @@ def test_activity_actions(self):
ACTION_LOCK_REMOTE_LOCK,
ACTION_LOCK_REMOTE_UNLATCH,
ACTION_LOCK_REMOTE_UNLOCK,
ACTION_LOCK_PIN_LOCK,
ACTION_LOCK_PIN_UNLATCH,
ACTION_LOCK_PIN_UNLOCK,
ACTION_LOCK_MANUAL_LOCK,
Expand Down Expand Up @@ -586,3 +588,21 @@ def test_finger_unlock_activity(self):
keypad_lock_activity.operator_thumbnail_url
== "https://d33mytkkohwnk6.cloudfront.net/app/ActivityFeedIcons/finger_unlock@3x.png"
)

def test_pin_lock_activity(self):
keypad_lock_activity = LockOperationActivity(
SOURCE_LOG, json.loads(load_fixture("pin_lock_activity.json"))
)
assert keypad_lock_activity.operated_by == "Sample Person"
assert keypad_lock_activity.operated_remote is False
assert keypad_lock_activity.operated_keypad is True
assert keypad_lock_activity.operated_manual is False
assert keypad_lock_activity.operated_tag is False
assert (
keypad_lock_activity.operator_image_url
== "https://d33mytkkohwnk6.cloudfront.net/app/ActivityFeedIcons/pin_lock@3x.png"
)
assert (
keypad_lock_activity.operator_thumbnail_url
== "https://d33mytkkohwnk6.cloudfront.net/app/ActivityFeedIcons/pin_lock@3x.png"
)
5 changes: 5 additions & 0 deletions yalexs/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
ACTION_LOCK_REMOTE_LOCK = "remote_lock"
ACTION_LOCK_REMOTE_UNLATCH = "remote_unlatch"
ACTION_LOCK_REMOTE_UNLOCK = "remote_unlock"
ACTION_LOCK_PIN_LOCK = "pin_lock"
ACTION_LOCK_PIN_UNLATCH = "pin_unlatch"
ACTION_LOCK_PIN_UNLOCK = "pin_unlock"
ACTION_LOCK_MANUAL_LOCK = "manual_lock"
Expand Down Expand Up @@ -97,6 +98,7 @@
ACTION_LOCK_REMOTE_LOCK,
ACTION_LOCK_REMOTE_UNLATCH,
ACTION_LOCK_REMOTE_UNLOCK,
ACTION_LOCK_PIN_LOCK,
ACTION_LOCK_PIN_UNLATCH,
ACTION_LOCK_PIN_UNLOCK,
ACTION_LOCK_MANUAL_LOCK,
Expand Down Expand Up @@ -128,6 +130,7 @@
ACTION_LOCK_MANUAL_UNLOCK: ("Manual", "Unlock"),
ACTION_LOCK_FINGER_LOCK: ("Fingerprint", "Lock"),
ACTION_LOCK_FINGER_UNLOCK: ("Fingerprint", "Unlock"),
ACTION_LOCK_PIN_LOCK: ("Pin", "Lock"),
ACTION_LOCK_PIN_UNLATCH: ("Pin", "Unlatch"),
ACTION_LOCK_PIN_UNLOCK: ("Pin", "Unlock"),
}
Expand All @@ -143,6 +146,7 @@
KEYPAD_ACTIONS = {
ACTION_LOCK_ONETOUCHLOCK,
ACTION_LOCK_ONETOUCHLOCK_2,
ACTION_LOCK_PIN_LOCK,
ACTION_LOCK_PIN_UNLATCH,
ACTION_LOCK_PIN_UNLOCK,
ACTION_LOCK_FINGER_LOCK,
Expand Down Expand Up @@ -201,6 +205,7 @@
ACTION_LOCK_REMOTE_LOCK: LockStatus.LOCKED,
ACTION_LOCK_REMOTE_UNLATCH: LockStatus.UNLATCHED,
ACTION_LOCK_REMOTE_UNLOCK: LockStatus.UNLOCKED,
ACTION_LOCK_PIN_LOCK: LockStatus.LOCKED,
ACTION_LOCK_PIN_UNLATCH: LockStatus.UNLATCHED,
ACTION_LOCK_PIN_UNLOCK: LockStatus.UNLOCKED,
ACTION_LOCK_MANUAL_LOCK: LockStatus.LOCKED,
Expand Down
Loading