def do_test(self): import logging logging.getLogger().setLevel(logging.DEBUG) endicia = Endicia(**settings.ENDICIA_CONF) endicia.format_xml = True print 'Querying label...' res = endicia.get_postage_label( weight=7, image_format=ImageFormat.GIF, mail_class=MailClass.First, mailpiece_shape=MailpieceShape.Parcel, stealth=False, rubber_stamp='CUSTOMER ID: 00000ABC\nORDER # 0000EFGH', services={ 'delivery_confirmation': False, }, reference_id='Store', description='Buy Shipping Label', partner_customer_id='00000ABC', partner_transaction_id='0000EFGH', to={ 'name': 'MARY WALZ', 'company': 'ENDICIA', 'address1': '247 HIGH ST', 'city': 'PALO ALTO', 'state': 'CA', 'postal_code': '94301', 'zip4': '0000', 'delivery_point': '00', 'country': 'United States', }, return_address='PO BOX 6487', frm={ 'name': 'GAMEMINE', 'city': 'DELRAY BEACH', 'state': 'FL', 'postal_code': '33482', 'zip4': '9901', }, postage_price=True) print ' PIC:', res.PIC print 'Checking status...' res = endicia.status_request(res.PIC, '9122148008600123456781') if isinstance(res.StatusList, list): for i in res.StatusList: i = i.PICNumber print ' %s: %s (%s)' % (i.PICNumber, i.StatusCode, i.Status) else: i = res.StatusList.PICNumber print ' %s: %s (%s)' % (i.PICNumber, i.StatusCode, i.Status) print 'DONE'
class EndiciaTests(TestCase): def setUp(self): self.endicia = Endicia(None, None, None, test_mode=True) def test_get_postage_label(self): # Outgoing mail label reply_postage = False description = "Rental Mailing Shipping Label" res_outgoing = self.endicia.get_postage_label( type=LabelType.DestinationConfirm, size=LabelSize.Dymo30384, image_format=ImageFormat.GIF, mail_class=MailClass.First, date_advance=7, weight=3.5, mailpiece_shape=MailpieceShape.Letter, machinable=True, sort_type=SortType.SinglePiece, include_postage=True, show_return_address=False, reply_postage=reply_postage, stealth=False, signature_waiver=True, no_weekend_delivery=False, no_holiday_delivery=True, return_to_sender=True, barcode_format="PLATNET Code, 14", cost_center=1, description=description, reference_id="Rent", partner_customer_id="12345678", partner_transaction_id="87654321", to={ "name": "Test Name", "address1": "1 Test St", "address2": "", "city": "Test City", "state": "Test State", "postal_code": "05105-123", "zip4": "1234", "delivery_point": "00", }, frm={ "city": u"DELRAY BEACH", "name": "GAMEMINE", "postal_code": u"33482-9901", "state": u"FL", "zip4": u"9901" }, return_address="PO BOX 6487", postage_price=True) self.assertTrue(res_outgoing.Base64LabelImage) # Incoming mail label reply_postage = True res_incoming = self.endicia.get_postage_label( type=LabelType.DestinationConfirm, size=LabelSize.Dymo30384, image_format=ImageFormat.GIF, mail_class=MailClass.First, date_advance=7, weight=3.5, mailpiece_shape=MailpieceShape.Letter, machinable=True, sort_type=SortType.SinglePiece, include_postage=True, show_return_address=False, reply_postage=reply_postage, stealth=False, signature_waiver=True, no_weekend_delivery=False, no_holiday_delivery=True, return_to_sender=True, barcode_format="PLATNET Code, 14", cost_center=1, description=description, reference_id="Rent", partner_customer_id="12345678", partner_transaction_id="87654321", to={ "name": "Test Name", "address1": "1 Test St", "address2": "", "city": "Test City", "state": "Test State", "postal_code": "05105-123", "zip4": "1234", "delivery_point": "00", }, frm={ "city": u"DELRAY BEACH", "name": "GAMEMINE", "postal_code": u"33482-9901", "state": u"FL", "zip4": u"9901" }, return_address="PO BOX 6487", postage_price=True) self.assertNotEqual(res_incoming.Base64LabelImage, res_outgoing.Base64LabelImage) def test_status_request(self): resp = self.endicia.status_request(12345) self.assertEqual(resp.StatusList.PICNumber.PICNumber, 12345) resp = self.endicia.status_request(12345, 54321) self.assertEqual(resp.StatusList[0].PICNumber, 12345) self.assertEqual(resp.StatusList[1].PICNumber, 54321) self.endicia.test_status_response = "D" resp = self.endicia.status_request(12345) self.assertEqual(resp.StatusList.PICNumber.StatusCode, "D")