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")
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_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_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")
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")
def test_parsing_service_center_address(data, type_of_number, number_plan, number): assert service_center_address.parse(data) == AddressField( type_of_number, number_plan, number)
def test_building_service_center_address(type_of_number, number_plan, number, expected): assert service_center_address.build( AddressField(type_of_number, number_plan, number)) == expected
def test_parsing_bcd_address(data, type_of_number, number_plan, number): assert bcd_address.parse(data) == AddressField(type_of_number, number_plan, number)
def test_building_bcd_address(type_of_number, number_plan, number, expected): assert bcd_address.build(AddressField(type_of_number, number_plan, number)) == expected