from data_gateway_sdk.protocols.smpm.smpm_dl_device_energy_16b_get_data import SmpmDlDeviceEnergy16BGetDataData, SmpmDlDeviceEnergy16bGetDataDataRequestMonth, \
    SmpmDlDeviceEnergy16bGetDataDataRequestId
from data_gateway_sdk.utils.buf_ref import BufRef


def test_smpm_dl_device_energy_16b_get_data() -> None:
    case_serialized = bytes.fromhex("8101c5cb0c3e83c9a032e00d00000000")
    assert SmpmDlDeviceEnergy16BGetDataData(year=2032, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.JAN, day=15, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.MONTHLY_ENERGY_ACTIVE_CONSUMED, SmpmDlDeviceEnergy16bGetDataDataRequestId.MONTHLY_ENERGY_REACTIVE_CONSUMED, SmpmDlDeviceEnergy16bGetDataDataRequestId.DAILY_ENERGY_ACTIVE_CONSUMED_TARIFF_3, SmpmDlDeviceEnergy16bGetDataDataRequestId.DAILY_ENERGY_ACTIVE_CONSUMED_TARIFF_SUM, SmpmDlDeviceEnergy16bGetDataDataRequestId.NETWORK_PARAMS_PHASE1, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED)) == SmpmDlDeviceEnergy16BGetDataData.parse(BufRef(case_serialized))  # noqa: E501
    case_serialized = bytes.fromhex("810130c80c3e83c9a032e00d00000000")  # overflow
    assert SmpmDlDeviceEnergy16BGetDataData(year=2000, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.DEC, day=0, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.MONTHLY_ENERGY_ACTIVE_CONSUMED, SmpmDlDeviceEnergy16bGetDataDataRequestId.MONTHLY_ENERGY_REACTIVE_CONSUMED, SmpmDlDeviceEnergy16bGetDataDataRequestId.DAILY_ENERGY_ACTIVE_CONSUMED_TARIFF_3, SmpmDlDeviceEnergy16bGetDataDataRequestId.DAILY_ENERGY_ACTIVE_CONSUMED_TARIFF_SUM, SmpmDlDeviceEnergy16bGetDataDataRequestId.NETWORK_PARAMS_PHASE1, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED)) == SmpmDlDeviceEnergy16BGetDataData.parse(BufRef(case_serialized))  # noqa: E501
    case_serialized = bytes.fromhex("81f933c80c3e83c9a032e00d00000000")  # overflow
    assert SmpmDlDeviceEnergy16BGetDataData(year=2127, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.DEC, day=0, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.MONTHLY_ENERGY_ACTIVE_CONSUMED, SmpmDlDeviceEnergy16bGetDataDataRequestId.MONTHLY_ENERGY_REACTIVE_CONSUMED, SmpmDlDeviceEnergy16bGetDataDataRequestId.DAILY_ENERGY_ACTIVE_CONSUMED_TARIFF_3, SmpmDlDeviceEnergy16bGetDataDataRequestId.DAILY_ENERGY_ACTIVE_CONSUMED_TARIFF_SUM, SmpmDlDeviceEnergy16bGetDataDataRequestId.NETWORK_PARAMS_PHASE1, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED)) == SmpmDlDeviceEnergy16BGetDataData.parse(BufRef(case_serialized))  # noqa: E501
    case_serialized = bytes.fromhex("8101f0cf0c3e83c9a032e00d00000000")  # overflow
    assert SmpmDlDeviceEnergy16BGetDataData(year=2000, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.DEC, day=31, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.MONTHLY_ENERGY_ACTIVE_CONSUMED, SmpmDlDeviceEnergy16bGetDataDataRequestId.MONTHLY_ENERGY_REACTIVE_CONSUMED, SmpmDlDeviceEnergy16bGetDataDataRequestId.DAILY_ENERGY_ACTIVE_CONSUMED_TARIFF_3, SmpmDlDeviceEnergy16bGetDataDataRequestId.DAILY_ENERGY_ACTIVE_CONSUMED_TARIFF_SUM, SmpmDlDeviceEnergy16bGetDataDataRequestId.NETWORK_PARAMS_PHASE1, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED)) == SmpmDlDeviceEnergy16BGetDataData.parse(BufRef(case_serialized))  # noqa: E501
    case_serialized = bytes.fromhex("81f9f3cf0c3e83c9a032e00d00000000")  # overflow
    assert SmpmDlDeviceEnergy16BGetDataData(year=2127, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.DEC, day=31, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.MONTHLY_ENERGY_ACTIVE_CONSUMED, SmpmDlDeviceEnergy16bGetDataDataRequestId.MONTHLY_ENERGY_REACTIVE_CONSUMED, SmpmDlDeviceEnergy16bGetDataDataRequestId.DAILY_ENERGY_ACTIVE_CONSUMED_TARIFF_3, SmpmDlDeviceEnergy16bGetDataDataRequestId.DAILY_ENERGY_ACTIVE_CONSUMED_TARIFF_SUM, SmpmDlDeviceEnergy16bGetDataDataRequestId.NETWORK_PARAMS_PHASE1, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED)) == SmpmDlDeviceEnergy16BGetDataData.parse(BufRef(case_serialized))  # noqa: E501
