예제 #1
0
def test_building_sms_submit_without_data_header():
    destination_address = AddressField(
        number_type.INTERNATIONAL_NUMBER,
        plan.UNKNOWN,
        "123456"
    )
    sms_submit = SmsSubmit(
        False,
        tp_srr.STATUS_REPORT_NOT_REQUESTED,
        tp_rd.ACCEPT,
        0xcc,
        destination_address,
        tp_pid.DEFAULT,
        TpDcsGeneralDataCodingIndicationNoMessageClass(),
        TpVpEnhanced(False, False, TpVpEnhancedSemiOctet(3, 4, 5)),
        TpUserData(
            "Deliver us!"
        )
    )
    assert build(L3Message(
        3,
        protocol_discriminator.SMS,
        CpData(rp_mti.RP_DATA_MS_TO_N, RpDataMsToN(
            1,
            destination_address,
            sms_submit
        ))
    )) == (b"\x39\x01\x24\x00\x01\x00\x04\x90\x21\x43\x65\x1b\x09\xcc\x06\x90"
           b"\x21\x43\x65\x00\x00\x03\x30\x40\x50\x00\x00\x00\x0b\xc4\x32\x3b"
           b"\x6d\x2f\xcb\x41\xf5\x79\x08")
예제 #2
0
def test_building_sms_submit_with_data_header():
    destination_address = AddressField(
        number_type.INTERNATIONAL_NUMBER,
        plan.UNKNOWN,
        "*3639"
    )
    sms_submit = SmsSubmit(
        False,
        tp_srr.STATUS_REPORT_NOT_REQUESTED,
        tp_rd.ACCEPT,
        0xcc,
        destination_address,
        tp_pid.DEFAULT,
        TpDcsGeneralDataCodingIndicationNoMessageClass(),
        TpVpAbsolute(18, 9, 1, 23, 6, 0, 2),
        TpUserData(
            "Deliver us!",
            TpUserDataHeader(TpUserDataHeaderElement(
                tp_udh_elements.CONCATENATED_SHORT_MESSAGES_8_BIT,
                b"\x03\x02\x01"
            ))
        )
    )
    assert build(L3Message(
        3,
        protocol_discriminator.SMS,
        CpData(rp_mti.RP_DATA_MS_TO_N, RpDataMsToN(
            1,
            destination_address,
            sms_submit
        ))
    )) == (b"\x39\x01\x2a\x00\x01\x00\x04\x90\x3a\x36\xf9\x21\x59\xcc\x05\x90"
           b"\x3a\x36\xf9\x00\x00\x81\x90\x10\x32\x60\x00\x80\x12\x05\x00\x03"
           b"\x03\x02\x01\x88\x65\x76\xda\x5e\x96\x83\xea\xf3\x10")
def test_building_rp_error_full():
    assert build(L3Message(
        3,
        protocol_discriminator.SMS,
        CpData(
            rp_mti.RP_ERROR_MS_TO_N,
            RpError(
                1,
                RpCause(rp_cause.PROTOCOL_ERROR, 0x44),
                RpErrorSmsDeliverReport(
                    tp_fcs.SIM_APPLICATION_TOOLKIT_BUSY,
                    tp_pid.X_400_BASED,
                    TpDcsGeneralDataCodingIndicationNoMessageClass(),
                    TpUserData(
                        "This is Part 2.",
                        TpUserDataHeader(TpUserDataHeaderElement(
                            tp_udh_elements.CONCATENATED_SHORT_MESSAGES_8_BIT,
                            b"\x03\x02\x02"
                        ))
                    )
                )
            )
        )
    )) == (b"\x39\x01\x21\x04\x01\x02\x6f\x44\x41\x1a\x40\xd4\x07\x31\x00"
           b"\x16\x05\x00\x03\x03\x02\x02\xa8\xe8\xf4\x1c\x94\x9e\x83\xa0"
           b"\x61\x39\x1d\x24\x73\x01")
def test_building_rp_error_with_diagnostic_field():
    assert build(L3Message(
        3,
        protocol_discriminator.SMS,
        CpData(rp_mti.RP_ERROR_MS_TO_N,
               RpError(1, RpCause(rp_cause.CALL_BARRED, 0xaa)))
    )) == b"\x39\x01\x05\x04\x01\x02\x0a\xaa"
예제 #5
0
def test_building_rp_ack_with_short_rp_user_data_submit():
    assert build(
        L3Message(
            3, protocol_discriminator.SMS,
            CpData(
                rp_mti.RP_ACK_N_TO_MS,
                RpAck(1, RpAckSmsSubmitReport(TpScts(18, 9, 1, 23, 6, 0, 2)))))
    ) == b"\x39\x01\x0d\x03\x01\x41\x09\x01\x00\x81\x90\x10\x32\x60\x00\x80"
def test_building_rp_error_with_short_rp_user_data_deliver():
    assert build(L3Message(
        3,
        protocol_discriminator.SMS,
        CpData(
            rp_mti.RP_ERROR_MS_TO_N,
            RpError(1, rp_cause.CALL_BARRED,
                    RpErrorSmsDeliverReport(tp_fcs.SC_BUSY))
        )
    )) == b"\x39\x01\x09\x04\x01\x01\x0a\x41\x03\x00\xc0\x00"
def test_building_sms_command_without_data_header():
    destination_address = AddressField(number_type.INTERNATIONAL_NUMBER,
                                       plan.UNKNOWN, "123456")
    sms_command = SmsCommand(tp_srr.STATUS_REPORT_REQUESTED, 0xcd,
                             tp_pid.DEFAULT,
                             tp_ct.DELETE_PREVIOUSLY_SUBMITTED_SM, 0xcc,
                             destination_address, TpUserData(b"Deliver us!"))
    assert build(
        L3Message(
            3, protocol_discriminator.SMS,
            CpData(rp_mti.RP_DATA_MS_TO_N,
                   RpDataMsToN(1, destination_address, sms_command)))
    ) == (b"\x39\x01\x1f\x00\x01\x00\x04\x90\x21\x43\x65\x16\x22\xcd\x00\x02"
          b"\xcc\x06\x90\x21\x43\x65\x0b\x44\x65\x6c\x69\x76\x65\x72\x20\x75"
          b"\x73\x21")
def test_building_rp_error_with_short_rp_user_data_submit():
    assert build(L3Message(
        3,
        protocol_discriminator.SMS,
        CpData(
            rp_mti.RP_ERROR_N_TO_MS,
            RpError(
                1,
                rp_cause.CALL_BARRED,
                RpErrorSmsSubmitReport(
                    tp_fcs.SC_BUSY,
                    TpScts(18, 9, 1, 23, 6, 0, 2)
                )
            )
        )
    )) == (b"\x39\x01\x10\x05\x01\x01\x0a\x41\x0a\x01\xc0\x00\x81\x90\x10"
           b"\x32\x60\x00\x80")
예제 #9
0
def test_building_sms_deliver_without_data_header():
    originator_address = AddressField(number_type.INTERNATIONAL_NUMBER,
                                      plan.UNKNOWN, "123456")
    sms_deliver = SmsDeliver(False, tp_sri.STATUS_REPORT_SHALL_BE_RETURNED,
                             tp_lp.NOT_FORWARDED_OR_SPAWNED,
                             tp_mms.NO_MORE_MESSAGES_ARE_WAITING,
                             originator_address, tp_pid.DEFAULT,
                             TpDcsGeneralDataCodingIndicationNoMessageClass(),
                             TpScts(18, 9, 1, 23, 6, 0, 2),
                             TpUserData("Deliver us!"))
    assert build(
        L3Message(
            3, protocol_discriminator.SMS,
            CpData(rp_mti.RP_DATA_N_TO_MS,
                   RpDataNToMs(1, originator_address, sms_deliver)))
    ) == (b"\x39\x01\x23\x01\x01\x04\x90\x21\x43\x65\x00\x1a\x24\x06\x90\x21"
          b"\x43\x65\x00\x00\x81\x90\x10\x32\x60\x00\x80\x0b\xc4\x32\x3b\x6d"
          b"\x2f\xcb\x41\xf5\x79\x08")
예제 #10
0
def test_building_rp_ack_full():
    a = build(
        L3Message(
            3, protocol_discriminator.SMS,
            CpData(
                rp_mti.RP_ACK_MS_TO_N,
                RpAck(
                    1,
                    RpAckSmsDeliverReport(
                        tp_pid.X_400_BASED,
                        TpDcsGeneralDataCodingIndicationNoMessageClass(),
                        TpUserData(
                            "This is Part 1.",
                            TpUserDataHeader(
                                TpUserDataHeaderElement(
                                    tp_udh_elements.
                                    CONCATENATED_SHORT_MESSAGES_8_BIT,
                                    b"\x03\x02\x01"))))))))
    assert a == (b"\x39\x01\x1d\x02\x01\x41\x19\x40\x07\x31\x00\x16\x05\x00"
                 b"\x03\x03\x02\x01\xa8\xe8\xf4\x1c\x94\x9e\x83\xa0\x61\x39"
                 b"\x1d\x14\x73\x01")
예제 #11
0
def test_building_sms_deliver_with_data_header():
    originator_address = AddressField(number_type.INTERNATIONAL_NUMBER,
                                      plan.UNKNOWN, "123456")
    sms_deliver = SmsDeliver(
        False, tp_sri.STATUS_REPORT_SHALL_BE_RETURNED,
        tp_lp.NOT_FORWARDED_OR_SPAWNED, tp_mms.NO_MORE_MESSAGES_ARE_WAITING,
        originator_address, tp_pid.DEFAULT,
        TpDcsGeneralDataCodingIndicationNoMessageClass(),
        TpScts(18, 9, 1, 23, 6, 0, 2),
        TpUserData(
            "Deliver us!",
            TpUserDataHeader(
                TpUserDataHeaderElement(
                    tp_udh_elements.CONCATENATED_SHORT_MESSAGES_8_BIT,
                    b"\x03\x02\x01"))))
    assert build(
        L3Message(
            3, protocol_discriminator.SMS,
            CpData(rp_mti.RP_DATA_N_TO_MS,
                   RpDataNToMs(1, originator_address, sms_deliver)))
    ) == (b"\x39\x01\x29\x01\x01\x04\x90\x21\x43\x65\x00\x20\x64\x06\x90\x21"
          b"\x43\x65\x00\x00\x81\x90\x10\x32\x60\x00\x80\x12\x05\x00\x03\x03"
          b"\x02\x01\x88\x65\x76\xda\x5e\x96\x83\xea\xf3\x10")
예제 #12
0
def test_building_rp_smma():
    assert build(L3Message(
        3,
        protocol_discriminator.SMS,
        CpData(rp_mti.RP_SMMA, RpSmma(1))
    )) == b"\x39\x01\x02\x06\x01"
예제 #13
0
def test_building_minimal_rp_error():
    assert build(L3Message(
        3,
        protocol_discriminator.SMS,
        CpData(rp_mti.RP_ERROR_MS_TO_N, RpError(1, rp_cause.INTERWORKING))
    )) == b"\x39\x01\x04\x04\x01\x01\x7f"
예제 #14
0
def test_building_rp_ack_to_ms():
    assert build(
        L3Message(3, protocol_discriminator.SMS,
                  CpData(rp_mti.RP_ACK_N_TO_MS,
                         RpAck(1)))) == b"\x39\x01\x02\x03\x01"
예제 #15
0
def test_building_rp_ack_with_short_rp_user_data_deliver():
    assert build(
        L3Message(
            3, protocol_discriminator.SMS,
            CpData(rp_mti.RP_ACK_MS_TO_N, RpAck(1, RpAckSmsDeliverReport())))
    ) == b"\x39\x01\x06\x02\x01\x41\x02\x00\x00"