def create_sms_delivery_receipt(correlator, address, delivery_status): """ Helper for creating an ``notifySmsDeliveryReceipt`` element. """ return NOTIFICATION_NS.notifySmsDeliveryReceipt( NOTIFICATION_NS.correlator(correlator), NOTIFICATION_NS.deliveryStatus( L.address(format_address(normalize_address(address))), L.deliveryStatus(delivery_status.name)))
def test_from_element_unknown_status(self): """ `DeliveryInformation.from_element` raises ``ValueError`` if an unknown ``DeliveryStatus`` enumeration value is specified. """ e = self.assertRaises( ValueError, DeliveryInformation.from_element, NOTIFICATION_NS.deliveryStatus(L.address('tel:27117654321'), L.deliveryStatus('WhatIsThis'))) self.assertEqual( "No such delivery status enumeration value: 'WhatIsThis'", str(e))
def test_from_element_unknown_status(self): """ `DeliveryInformation.from_element` raises ``ValueError`` if an unknown ``DeliveryStatus`` enumeration value is specified. """ e = self.assertRaises(ValueError, DeliveryInformation.from_element, NOTIFICATION_NS.deliveryStatus( L.address('tel:27117654321'), L.deliveryStatus('WhatIsThis'))) self.assertEqual( "No such delivery status enumeration value: 'WhatIsThis'", str(e))
def test_from_element(self): """ `DeliveryInformation.from_element` parses a ParlayX ``DeliveryInformation`` complex type into a `DeliveryInformation` instance. Known ``DeliveryStatus`` enumeration values are parsed into `DeliveryStatus` attributes. """ info = DeliveryInformation.from_element( NOTIFICATION_NS.deliveryStatus( L.address('tel:27117654321'), L.deliveryStatus('DeliveredToNetwork'))) self.assertEqual(('+27117654321', DeliveryStatus.DeliveredToNetwork), (info.address, info.delivery_status))
def test_from_element(self): """ `DeliveryInformation.from_element` parses a ParlayX ``DeliveryInformation`` complex type into a `DeliveryInformation` instance. Known ``DeliveryStatus`` enumeration values are parsed into `DeliveryStatus` attributes. """ info = DeliveryInformation.from_element( NOTIFICATION_NS.deliveryStatus( L.address('tel:27117654321'), L.deliveryStatus('DeliveredToNetwork'))) self.assertEqual( ('+27117654321', DeliveryStatus.DeliveredToNetwork), (info.address, info.delivery_status))