Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #210 from robmarkcole/add-remote-tests
Browse files Browse the repository at this point in the history
Adds test zgp
  • Loading branch information
robmarkcole authored Feb 11, 2020
2 parents a974bd5 + 4791b5a commit 5b048ed
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
5 changes: 0 additions & 5 deletions custom_components/huesensor/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ def parse_zgp(response):

def parse_rwl(response):
"""Parse the json response for a RWL Hue remote."""

"""
I know it should be _released not _up
but _hold_up is too good to miss isn't it
"""
responsecodes = {"0": "_click", "1": "_hold", "2": "_click_up", "3": "_hold_up"}

button = None
Expand Down
1 change: 0 additions & 1 deletion tests/test_binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Tests for binary_sensor.py
"""
import json
import custom_components.huesensor.binary_sensor as bs

MOCK_ZLLPresence = {
Expand Down
57 changes: 57 additions & 0 deletions tests/test_remote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""
Tests for binary_sensor.py
"""
import custom_components.huesensor.remote as remote

MOCK_ZGP = {
"state": {"buttonevent": 17, "lastupdated": "2019-06-22T14:43:50"},
"swupdate": {"state": "notupdatable", "lastinstall": None},
"config": {"on": True},
"name": "Hue Tap",
"type": "ZGPSwitch",
"modelid": "ZGPSWITCH",
"manufacturername": "Philips",
"productname": "Hue tap switch",
"diversityid": "d8cde5d5-0eef-4b95-b0f0-71ddd2952af4",
"uniqueid": "00:00:00:00:00:44:23:08-f2",
"capabilities": {"certified": True, "primary": True, "inputs": [],},
}

MOCK_RWL = {
"state": {"buttonevent": 4002, "lastupdated": "2019-12-28T21:58:02"},
"swupdate": {"state": "noupdates", "lastinstall": "2019-10-13T13:16:15"},
"config": {"on": True, "battery": 100, "reachable": True, "pending": []},
"name": "Hue dimmer switch 1",
"type": "ZLLSwitch",
"modelid": "RWL021",
"manufacturername": "Philips",
"productname": "Hue dimmer switch",
"diversityid": "73bbabea-3420-499a-9856-46bf437e119b",
"swversion": "6.1.1.28573",
"uniqueid": "00:17:88:01:10:3e:3a:dc-02-fc00",
"capabilities": {"certified": True, "primary": True, "inputs": []},
}

PARSED_ZGP = {
"last_button_event": "3_click",
"last_updated": ["2019-06-22", "14:43:50"],
"model": "ZGP",
"name": "Hue Tap",
"state": "3_click",
}

PARSED_RWL = {
"battery": 100,
"last_button_event": "4_click_up",
"last_updated": ["2019-12-28", "21:58:02"],
"model": "RWL",
"name": "Hue dimmer switch 1",
"on": True,
"reachable": True,
"state": "4_click_up",
}


def test_parse_zgp():
assert remote.parse_zgp(MOCK_ZGP) == PARSED_ZGP
assert remote.parse_rwl(MOCK_RWL) == PARSED_RWL

0 comments on commit 5b048ed

Please sign in to comment.