Skip to content

Commit

Permalink
test GetInverterInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
farmio committed Aug 22, 2021
1 parent 36c5fef commit c6f2552
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyfronius/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,9 @@ def _inverter_info(data):
{
**inverter_info,
"device_id": inverter_index,
"CustomName": unescape(inverter_info["CustomName"])
# "CustomName" not available on API V0 so default to ""
# html escaped by V1 Snap-In, UTF-8 by V1 Gen24
"CustomName": unescape(inverter_info.get("CustomName", ""))
}
for inverter_index, inverter_info in data.items()
]
Expand Down
29 changes: 29 additions & 0 deletions pyfronius/tests/test_structure/v0/solar_api/GetInverterInfo.cgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"Head": {
"RequestArguments": {},
"Status": {
"Code": 0,
"Reason": "",
"UserMessage": ""
},
"Timestamp": "2019-06-12T15:31:02+02:00"
},
"Body": {
"Data": {
"1": {
"DT": 192,
"PVPower": 5000,
"UniqueID": "123456",
"ErrorCode": 0,
"StatusCode": 7
},
"2": {
"DT": 192,
"PVPower": 5000,
"UniqueID": "234567",
"ErrorCode": 0,
"StatusCode": 7
}
}
}
}
51 changes: 51 additions & 0 deletions pyfronius/tests/test_structure/v1/solar_api/v1/GetInverterInfo.cgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"Body": {
"Data": {
"1": {
"CustomName": "Primo 8.2-1 (",
"DT": 102,
"ErrorCode": 0,
"PVPower": 500,
"Show": 1,
"StatusCode": 7,
"UniqueID": "38183"
},
"2": {
"CustomName": "Primo 5.0-1 20",
"DT": 86,
"ErrorCode": 0,
"PVPower": 500,
"Show": 1,
"StatusCode": 7,
"UniqueID": "16777215"
},
"3": {
"CustomName": "Galvo 3.1-1 20",
"DT": 106,
"ErrorCode": 0,
"PVPower": 500,
"Show": 1,
"StatusCode": 7,
"UniqueID": "7262"
},
"55": {
"CustomName": "Galvo 3.0-1 (5",
"DT": 224,
"ErrorCode": 0,
"PVPower": 500,
"Show": 1,
"StatusCode": 7,
"UniqueID": "100372"
}
}
},
"Head": {
"RequestArguments": {},
"Status": {
"Code": 0,
"Reason": "",
"UserMessage": ""
},
"Timestamp": "2019-06-12T15:31:02+02:00"
}
}
8 changes: 8 additions & 0 deletions pyfronius/tests/test_web_v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
GET_INVERTER_REALTIME_DATA_SCOPE_DEVICE,
GET_INVERTER_REALTIME_DATA_SYSTEM,
GET_LOGGER_INFO,
GET_INVERTER_INFO,
)

ADDRESS = "localhost"
Expand Down Expand Up @@ -220,6 +221,13 @@ def test_fronius_get_logger_info(self):
)
self.assertDictEqual(res, GET_LOGGER_INFO)

def test_fronius_get_inverter_info(self):
res = asyncio.get_event_loop().run_until_complete(
self.fronius.inverter_info()
)
self.maxDiff = None
self.assertDictEqual(res, GET_INVERTER_INFO)

def test_fronius_get_no_data(self):
# Storage data for device 0 is not provided ATM
# TODO someone add some storage data for a device 1?
Expand Down
7 changes: 7 additions & 0 deletions pyfronius/tests/test_web_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
GET_LOGGER_LED_INFO_STATE,
GET_POWER_FLOW_REALTIME_DATA,
GET_LOGGER_INFO,
GET_INVERTER_INFO,
)

ADDRESS = "localhost"
Expand Down Expand Up @@ -228,6 +229,12 @@ def test_fronius_get_logger_info(self):
)
self.assertDictEqual(res, GET_LOGGER_INFO)

def test_fronius_get_inverter_info(self):
res = asyncio.get_event_loop().run_until_complete(
self.fronius.inverter_info()
)
self.assertDictEqual(res, GET_INVERTER_INFO)

def test_fronius_get_no_data(self):
# Storage data for device 0 is not provided ATM
# TODO someone add some storage data for a device 1?
Expand Down
24 changes: 24 additions & 0 deletions pyfronius/tests/web_raw/v0/web_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,27 @@
"utc_offset": {"value": 7200},
"unique_identifier": {"value": "240.123456"},
}
GET_INVERTER_INFO = {
"timestamp": {"value": "2019-06-12T15:31:02+02:00"},
"status": {"Code": 0, "Reason": "", "UserMessage": ""},
"inverters": [
{
"device_id": "1",
"DT": 192,
"PVPower": 5000,
"UniqueID": "123456",
"ErrorCode": 0,
"StatusCode": 7,
"CustomName": "",
},
{
"device_id": "2",
"DT": 192,
"PVPower": 5000,
"UniqueID": "234567",
"ErrorCode": 0,
"StatusCode": 7,
"CustomName": "",
},
]
}
48 changes: 48 additions & 0 deletions pyfronius/tests/web_raw/v1/web_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,51 @@
"utc_offset": {"value": 7200},
"unique_identifier": {"value": "240.123456"},
}

GET_INVERTER_INFO = {

"timestamp": {"value": "2019-06-12T15:31:02+02:00"},
"status": {"Code": 0, "Reason": "", "UserMessage": ""},
"inverters": [
{
"device_id": "1",
"CustomName": "Primo 8.2-1 (",
"DT": 102,
"ErrorCode": 0,
"PVPower": 500,
"Show": 1,
"StatusCode": 7,
"UniqueID": "38183",
},
{
"device_id": "2",
"CustomName": "Primo 5.0-1 20",
"DT": 86,
"ErrorCode": 0,
"PVPower": 500,
"Show": 1,
"StatusCode": 7,
"UniqueID": "16777215",
},
{
"device_id": "3",
"CustomName": "Galvo 3.1-1 20",
"DT": 106,
"ErrorCode": 0,
"PVPower": 500,
"Show": 1,
"StatusCode": 7,
"UniqueID": "7262",
},
{
"device_id": "55",
"CustomName": "Galvo 3.0-1 (5",
"DT": 224,
"ErrorCode": 0,
"PVPower": 500,
"Show": 1,
"StatusCode": 7,
"UniqueID": "100372",
},
]
}

0 comments on commit c6f2552

Please sign in to comment.