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("8101c5db090000000000000000000000")
    assert SmpmDlDeviceEnergy16BGetDataData(year=2032, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.JAN, day=15, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.UL_DATA_16B__ENERGY, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED)) == SmpmDlDeviceEnergy16BGetDataData.parse(BufRef(case_serialized))  # noqa: E501
    assert case_serialized == SmpmDlDeviceEnergy16BGetDataData.serialize(SmpmDlDeviceEnergy16BGetDataData(year=2032, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.JAN, day=15, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.UL_DATA_16B__ENERGY, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED)))  # noqa: E501
    case_serialized = bytes.fromhex("810130d8090000000000000000000000")  # overflow
    assert SmpmDlDeviceEnergy16BGetDataData(year=2000, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.DEC, day=0, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.UL_DATA_16B__ENERGY, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED)) == SmpmDlDeviceEnergy16BGetDataData.parse(BufRef(case_serialized))  # noqa: E501
    assert case_serialized == SmpmDlDeviceEnergy16BGetDataData.serialize(SmpmDlDeviceEnergy16BGetDataData(day=0, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.DEC, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.UL_DATA_16B__ENERGY, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED), year=2000))  # noqa: E501
    case_serialized = bytes.fromhex("81f933d8090000000000000000000000")  # overflow
    assert SmpmDlDeviceEnergy16BGetDataData(year=2127, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.DEC, day=0, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.UL_DATA_16B__ENERGY, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED)) == SmpmDlDeviceEnergy16BGetDataData.parse(BufRef(case_serialized))  # noqa: E501
    assert case_serialized == SmpmDlDeviceEnergy16BGetDataData.serialize(SmpmDlDeviceEnergy16BGetDataData(day=0, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.DEC, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.UL_DATA_16B__ENERGY, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED), year=2127))  # noqa: E501
    case_serialized = bytes.fromhex("8101f0df090000000000000000000000")  # overflow
    assert SmpmDlDeviceEnergy16BGetDataData(year=2000, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.DEC, day=31, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.UL_DATA_16B__ENERGY, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED)) == SmpmDlDeviceEnergy16BGetDataData.parse(BufRef(case_serialized))  # noqa: E501
    assert case_serialized == SmpmDlDeviceEnergy16BGetDataData.serialize(SmpmDlDeviceEnergy16BGetDataData(day=31, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.DEC, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.UL_DATA_16B__ENERGY, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED), year=2000))  # noqa: E501
    case_serialized = bytes.fromhex("81f9f3df090000000000000000000000")  # overflow
    assert SmpmDlDeviceEnergy16BGetDataData(year=2127, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.DEC, day=31, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.UL_DATA_16B__ENERGY, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED)) == SmpmDlDeviceEnergy16BGetDataData.parse(BufRef(case_serialized))  # noqa: E501
    assert case_serialized == SmpmDlDeviceEnergy16BGetDataData.serialize(SmpmDlDeviceEnergy16BGetDataData(day=31, month=SmpmDlDeviceEnergy16bGetDataDataRequestMonth.DEC, request_data_pack_ids=(SmpmDlDeviceEnergy16bGetDataDataRequestId.UL_DATA_16B__ENERGY, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED, SmpmDlDeviceEnergy16bGetDataDataRequestId.UNDEFINED), year=2127))  # noqa: E501
