Skip to content

Commit

Permalink
Move additional tests to golden files (#79)
Browse files Browse the repository at this point in the history
Move additional tests to golden files out of the fixture. This is to
help support additional support like re-encoding and expanding to
request decoding.
  • Loading branch information
allenporter authored Jan 10, 2023
1 parent 19bbccc commit 13bb8b4
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 95 deletions.
95 changes: 0 additions & 95 deletions tests/test_rainbird.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,98 +57,3 @@ class TestSequence(unittest.TestCase):
)
def test_encode(self, expected, command, *vargs):
self.assertEqual(expected, encode(command, *vargs))

@parameterized.expand(
[
[
{
"type": "NotAcknowledgeResponse",
"commandEcho": 2,
"NAKCode": 3,
},
"000203",
],
[{"type": "AcknowledgeResponse", "commandEcho": 6}, "0106"],
[
{
"type": "ModelAndVersionResponse",
"modelID": 6,
"protocolRevisionMajor": 9,
"protocolRevisionMinor": 12,
},
"820006090C",
],
[
{
"type": "AvailableStationsResponse",
"pageNumber": 15,
"setStations": 16,
},
"830F0010",
],
[
{
"type": "CommandSupportResponse",
"commandEcho": 0x82,
"support": 1,
},
"848201",
],
[
{"type": "SerialNumberResponse", "serialNumber": 0x8963},
"850000000000008963",
],
[
{
"type": "CurrentTimeResponse",
"hour": 12,
"minute": 54,
"second": 35,
},
"900C3623",
],
[
{
"type": "CurrentDateResponse",
"day": 18,
"month": 11,
"year": 2018,
},
"9212B7E2",
],
[
{
"type": "WaterBudgetResponse",
"programCode": 3,
"seasonalAdjust": 0x83,
},
"B0030083",
],
[
{"type": "CurrentRainSensorStateResponse", "sensorState": 1},
"BE01",
],
[
{
"type": "CurrentStationsActiveResponse",
"pageNumber": 1,
"activeStations": 0b00010000000000000000000000000000,
},
"BF0110000000",
],
[
{"type": "RainDelaySettingResponse", "delaySetting": 3},
"B60003",
],
[
{
"type": "CurrentIrrigationStateResponse",
"irrigationState": 1,
},
"C801",
],
],
name_func=decode_name_func,
)
def test_decode(self, expected, data):
self.assertEqual(expected, decode(data))
13 changes: 13 additions & 0 deletions tests/testdata/ack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
data:
- "0106"
- "000203"
- "848201"
decoded_data:
- type: AcknowledgeResponse
commandEcho: 6
- type: NotAcknowledgeResponse
commandEcho: 2
NAKCode: 3
- type: CommandSupportResponse
commandEcho: 0x82
support: 1
6 changes: 6 additions & 0 deletions tests/testdata/available_stations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
data:
- 830F0010
decoded_data:
- type: AvailableStationsResponse
pageNumber: 15
setStations: 16
13 changes: 13 additions & 0 deletions tests/testdata/date_time.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
data:
- "900C3623"
- "9212B7E2"
decoded_data:
- type: CurrentTimeResponse
hour: 12
minute: 54
second: 35
- type: CurrentDateResponse
year: 2018
month: 11
day: 18

5 changes: 5 additions & 0 deletions tests/testdata/irrigation_state.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data:
- "C801"
decoded_data:
- type: CurrentIrrigationStateResponse
irrigationState: 1
10 changes: 10 additions & 0 deletions tests/testdata/model_and_version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
data:
- "820006090C"
- "850000000000008963"
decoded_data:
- type: ModelAndVersionResponse
modelID: 6
protocolRevisionMajor: 9
protocolRevisionMinor: 12
- type: SerialNumberResponse
serialNumber: 0x8963
5 changes: 5 additions & 0 deletions tests/testdata/rain_delay.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data:
- "B60003"
decoded_data:
- type: RainDelaySettingResponse
delaySetting: 3
5 changes: 5 additions & 0 deletions tests/testdata/rain_sensor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data:
- "BE01"
decoded_data:
- type: CurrentRainSensorStateResponse
sensorState: 1

0 comments on commit 13bb8b4

Please sign in to comment.