Update aioqsw to v0.2.0 (#76509)

pull/75652/head^2
Álvaro Fernández Rojas 2022-08-09 15:24:53 +02:00 committed by GitHub
parent f90d007e73
commit 46a8f19197
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 350 additions and 3 deletions

View File

@ -3,7 +3,7 @@
"name": "QNAP QSW", "name": "QNAP QSW",
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/qnap_qsw", "documentation": "https://www.home-assistant.io/integrations/qnap_qsw",
"requirements": ["aioqsw==0.1.1"], "requirements": ["aioqsw==0.2.0"],
"codeowners": ["@Noltari"], "codeowners": ["@Noltari"],
"iot_class": "local_polling", "iot_class": "local_polling",
"loggers": ["aioqsw"], "loggers": ["aioqsw"],

View File

@ -232,7 +232,7 @@ aiopvpc==3.0.0
aiopyarr==22.7.0 aiopyarr==22.7.0
# homeassistant.components.qnap_qsw # homeassistant.components.qnap_qsw
aioqsw==0.1.1 aioqsw==0.2.0
# homeassistant.components.recollect_waste # homeassistant.components.recollect_waste
aiorecollect==1.0.8 aiorecollect==1.0.8

View File

@ -207,7 +207,7 @@ aiopvpc==3.0.0
aiopyarr==22.7.0 aiopyarr==22.7.0
# homeassistant.components.qnap_qsw # homeassistant.components.qnap_qsw
aioqsw==0.1.1 aioqsw==0.2.0
# homeassistant.components.recollect_waste # homeassistant.components.recollect_waste
aiorecollect==1.0.8 aiorecollect==1.0.8

View File

@ -18,6 +18,8 @@ from .util import (
FIRMWARE_CONDITION_MOCK, FIRMWARE_CONDITION_MOCK,
FIRMWARE_INFO_MOCK, FIRMWARE_INFO_MOCK,
FIRMWARE_UPDATE_CHECK_MOCK, FIRMWARE_UPDATE_CHECK_MOCK,
PORTS_STATISTICS_MOCK,
PORTS_STATUS_MOCK,
SYSTEM_BOARD_MOCK, SYSTEM_BOARD_MOCK,
SYSTEM_SENSOR_MOCK, SYSTEM_SENSOR_MOCK,
SYSTEM_TIME_MOCK, SYSTEM_TIME_MOCK,
@ -44,6 +46,12 @@ async def test_coordinator_client_connector_error(hass: HomeAssistant) -> None:
"homeassistant.components.qnap_qsw.QnapQswApi.get_firmware_update_check", "homeassistant.components.qnap_qsw.QnapQswApi.get_firmware_update_check",
return_value=FIRMWARE_UPDATE_CHECK_MOCK, return_value=FIRMWARE_UPDATE_CHECK_MOCK,
) as mock_firmware_update_check, patch( ) as mock_firmware_update_check, patch(
"homeassistant.components.qnap_qsw.QnapQswApi.get_ports_statistics",
return_value=PORTS_STATISTICS_MOCK,
) as mock_ports_statistics, patch(
"homeassistant.components.qnap_qsw.QnapQswApi.get_ports_status",
return_value=PORTS_STATUS_MOCK,
) as mock_ports_status, patch(
"homeassistant.components.qnap_qsw.QnapQswApi.get_system_board", "homeassistant.components.qnap_qsw.QnapQswApi.get_system_board",
return_value=SYSTEM_BOARD_MOCK, return_value=SYSTEM_BOARD_MOCK,
) as mock_system_board, patch( ) as mock_system_board, patch(
@ -65,6 +73,8 @@ async def test_coordinator_client_connector_error(hass: HomeAssistant) -> None:
mock_firmware_condition.assert_called_once() mock_firmware_condition.assert_called_once()
mock_firmware_info.assert_called_once() mock_firmware_info.assert_called_once()
mock_firmware_update_check.assert_called_once() mock_firmware_update_check.assert_called_once()
mock_ports_statistics.assert_called_once()
mock_ports_status.assert_called_once()
mock_system_board.assert_called_once() mock_system_board.assert_called_once()
mock_system_sensor.assert_called_once() mock_system_sensor.assert_called_once()
mock_system_time.assert_called_once() mock_system_time.assert_called_once()
@ -74,6 +84,8 @@ async def test_coordinator_client_connector_error(hass: HomeAssistant) -> None:
mock_firmware_condition.reset_mock() mock_firmware_condition.reset_mock()
mock_firmware_info.reset_mock() mock_firmware_info.reset_mock()
mock_firmware_update_check.reset_mock() mock_firmware_update_check.reset_mock()
mock_ports_statistics.reset_mock()
mock_ports_status.reset_mock()
mock_system_board.reset_mock() mock_system_board.reset_mock()
mock_system_sensor.reset_mock() mock_system_sensor.reset_mock()
mock_system_time.reset_mock() mock_system_time.reset_mock()

View File

@ -18,6 +18,10 @@ from aioqsw.const import (
API_ERROR_MESSAGE, API_ERROR_MESSAGE,
API_FAN1_SPEED, API_FAN1_SPEED,
API_FAN2_SPEED, API_FAN2_SPEED,
API_FCS_ERRORS,
API_FULL_DUPLEX,
API_KEY,
API_LINK,
API_MAC_ADDR, API_MAC_ADDR,
API_MAX_SWITCH_TEMP, API_MAX_SWITCH_TEMP,
API_MESSAGE, API_MESSAGE,
@ -28,10 +32,15 @@ from aioqsw.const import (
API_PRODUCT, API_PRODUCT,
API_PUB_DATE, API_PUB_DATE,
API_RESULT, API_RESULT,
API_RX_ERRORS,
API_RX_OCTETS,
API_SERIAL, API_SERIAL,
API_SPEED,
API_SWITCH_TEMP, API_SWITCH_TEMP,
API_TRUNK_NUM, API_TRUNK_NUM,
API_TX_OCTETS,
API_UPTIME, API_UPTIME,
API_VAL,
API_VERSION, API_VERSION,
) )
@ -111,6 +120,326 @@ FIRMWARE_UPDATE_CHECK_MOCK = {
}, },
} }
PORTS_STATISTICS_MOCK = {
API_ERROR_CODE: 200,
API_ERROR_MESSAGE: "OK",
API_RESULT: [
{
API_KEY: "1",
API_VAL: {
API_RX_OCTETS: 20000,
API_RX_ERRORS: 20,
API_TX_OCTETS: 10000,
API_FCS_ERRORS: 10,
},
},
{
API_KEY: "2",
API_VAL: {
API_RX_OCTETS: 2000,
API_RX_ERRORS: 2,
API_TX_OCTETS: 1000,
API_FCS_ERRORS: 1,
},
},
{
API_KEY: "3",
API_VAL: {
API_RX_OCTETS: 200,
API_RX_ERRORS: 0,
API_TX_OCTETS: 100,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "4",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "5",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "6",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "7",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "8",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "9",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "10",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "11",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "12",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "29",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "30",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "31",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "32",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "33",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
{
API_KEY: "34",
API_VAL: {
API_RX_OCTETS: 0,
API_RX_ERRORS: 0,
API_TX_OCTETS: 0,
API_FCS_ERRORS: 0,
},
},
],
}
PORTS_STATUS_MOCK = {
API_ERROR_CODE: 200,
API_ERROR_MESSAGE: "OK",
API_RESULT: [
{
API_KEY: "1",
API_VAL: {
API_LINK: True,
API_FULL_DUPLEX: True,
API_SPEED: "10000",
},
},
{
API_KEY: "2",
API_VAL: {
API_LINK: True,
API_FULL_DUPLEX: True,
API_SPEED: "1000",
},
},
{
API_KEY: "3",
API_VAL: {
API_LINK: True,
API_FULL_DUPLEX: False,
API_SPEED: "100",
},
},
{
API_KEY: "4",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "1000",
},
},
{
API_KEY: "5",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "1000",
},
},
{
API_KEY: "6",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "1000",
},
},
{
API_KEY: "7",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "1000",
},
},
{
API_KEY: "8",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "1000",
},
},
{
API_KEY: "9",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "1000",
},
},
{
API_KEY: "10",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "1000",
},
},
{
API_KEY: "11",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "1000",
},
},
{
API_KEY: "12",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "1000",
},
},
{
API_KEY: "29",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "0",
},
},
{
API_KEY: "30",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "0",
},
},
{
API_KEY: "31",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "0",
},
},
{
API_KEY: "32",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "0",
},
},
{
API_KEY: "33",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "0",
},
},
{
API_KEY: "34",
API_VAL: {
API_LINK: False,
API_FULL_DUPLEX: False,
API_SPEED: "0",
},
},
],
}
SYSTEM_COMMAND_MOCK = { SYSTEM_COMMAND_MOCK = {
API_ERROR_CODE: 200, API_ERROR_CODE: 200,
API_ERROR_MESSAGE: "OK", API_ERROR_MESSAGE: "OK",
@ -170,6 +499,12 @@ async def async_init_integration(
), patch( ), patch(
"homeassistant.components.qnap_qsw.QnapQswApi.get_firmware_update_check", "homeassistant.components.qnap_qsw.QnapQswApi.get_firmware_update_check",
return_value=FIRMWARE_UPDATE_CHECK_MOCK, return_value=FIRMWARE_UPDATE_CHECK_MOCK,
), patch(
"homeassistant.components.qnap_qsw.QnapQswApi.get_ports_statistics",
return_value=PORTS_STATISTICS_MOCK,
), patch(
"homeassistant.components.qnap_qsw.QnapQswApi.get_ports_status",
return_value=PORTS_STATUS_MOCK,
), patch( ), patch(
"homeassistant.components.qnap_qsw.QnapQswApi.get_system_board", "homeassistant.components.qnap_qsw.QnapQswApi.get_system_board",
return_value=SYSTEM_BOARD_MOCK, return_value=SYSTEM_BOARD_MOCK,