コード例 #1
0
    def test_domestic_rate(self):
        """
        Ensure that Domestic Rate Calculator returns quotes in the expected format
        """
        connector = DomesticRateCalculator(USPS_CONNECTION, USERID, PASSWORD)
        response = connector.execute([
            {
                'Service': 'First Class',
                'FirstClassMailType': 'LETTER',
                'ZipOrigination': '44106',
                'ZipDestination': '97217',
                'Pounds': '0',
                'Ounces': '3.5',
                'Size': 'REGULAR',
                'Machinable': 'true'
            },
            {
                'Service': 'Priority',
                'ZipOrigination': '44106',
                'ZipDestination': '97217',
                'Pounds': '1',
                'Ounces': '8',
                'Container': 'NONRECTANGULAR',
                'Size': 'LARGE',
                'Width': '15',
                'Length': '30',
                'Height': '15',
                'Girth': '55'
            },
            {
                'Service': 'ALL',
                'FirstClassMailType': 'LETTER',
                'ZipOrigination': '90210',
                'ZipDestination': '97217',
                'Pounds': '8',
                'Ounces': '32',
                'Container': None,
                'Size': 'REGULAR',
                'Machinable': 'true'
            },
        ])

        for rate in [response[0], response[1]]:
            self.assertTrue('Postage' in rate)
            self.assertTrue('Rate' in rate['Postage'])

        self.assertTrue('Postage' in response[2])
        for postage in response[2]['Postage']:
            self.assertTrue('Rate' in postage)
            self.assertTrue('MailService' in postage)
コード例 #2
0
ファイル: tests.py プロジェクト: oliverseal/python-usps
    def test_domestic_rate(self):
        """
        Ensure that Domestic Rate Calculator returns quotes in the expected format
        """

        connector = DomesticRateCalculator(USPS_CONNECTION, USERID, PASSWORD)
        response = connector.execute([{'Service': 'First Class',
                                       'FirstClassMailType': 'LETTER',
                                       'ZipOrigination': '44106',
                                       'ZipDestination': '97217',
                                       'Pounds': '0',
                                       'Ounces': '3.5',
                                       'Size': 'REGULAR',
                                       'Machinable': 'true'
                                       }, 
                                       {
                                        'Service': 'Priority',
                                        'ZipOrigination': '44106',
                                        'ZipDestination': '97217',
                                        'Pounds': '1',
                                        'Ounces': '8',
                                        'Container': 'NONRECTANGULAR',
                                        'Size': 'LARGE',
                                        'Width': '15',
                                        'Length': '30',
                                        'Height': '15',
                                        'Girth': '55'
                                        },
                                        {'Service': 'ALL',
                                         'FirstClassMailType': 'LETTER',
                                         'ZipOrigination': '90210',
                                         'ZipDestination': '97217',
                                         'Pounds': '8',
                                         'Ounces': '32',
                                         'Container': None,
                                         'Size': 'REGULAR',
                                         'Machinable': 'true'
                                        },
                                        ])
        
        for rate in [response[0], response[1]]:
            self.assertTrue('Postage' in rate)
            self.assertTrue('Rate' in rate['Postage'])
            
        self.assertTrue('Postage' in response[2])
        for postage in response[2]['Postage']:
            self.assertTrue('Rate' in postage)
            self.assertTrue('MailService' in postage)
コード例 #3
0
ファイル: mytest.py プロジェクト: adewinter/python-usps
from usps.api import USPS_CONNECTION_TEST_SECURE, USPS_CONNECTION
from usps.api.addressinformation import AddressValidate, ZipCodeLookup, CityStateLookup
from usps.api.ratecalculator import DomesticRateCalculator, InternationalRateCalculator
from usps.api.servicestandards import PriorityMailServiceStandards, PackageServicesServiceStandards, ExpressMailServiceCommitment, get_service_standards
from usps.api.tracking import TrackConfirm
from pprint import pprint
import json

# Your Username is 621OLYMP1079
# Your Password is 228QM69IV159

USERID = "621OLYMP1079"
PASSWORD = "******"

connector = DomesticRateCalculator(USPS_CONNECTION, USERID, PASSWORD)
response = connector.execute([{'Service': 'First Class',
                               'FirstClassMailType': 'LETTER',
                               'ZipOrigination': '44106',
                               'ZipDestination': '97217',
                               'Pounds': '0',
                               'Ounces': '3.5',
                               'Size': 'REGULAR',
                               'Machinable': 'true'
                               }, 
                               {
                                'Service': 'Express',
                                'ZipOrigination': '44106',
                                'ZipDestination': '97217',
                                'Pounds': '1',
                                'Ounces': '8',
#                                'Container': 'RECTANGULAR',
コード例 #4
0
from usps.api import USPS_CONNECTION_TEST_SECURE, USPS_CONNECTION
from usps.api.addressinformation import AddressValidate, ZipCodeLookup, CityStateLookup
from usps.api.ratecalculator import DomesticRateCalculator, InternationalRateCalculator
from usps.api.servicestandards import PriorityMailServiceStandards, PackageServicesServiceStandards, ExpressMailServiceCommitment, get_service_standards
from usps.api.tracking import TrackConfirm
from pprint import pprint
import json

# Your Username is 621OLYMP1079
# Your Password is 228QM69IV159

USERID = "621OLYMP1079"
PASSWORD = "******"

connector = DomesticRateCalculator(USPS_CONNECTION, USERID, PASSWORD)
response = connector.execute([
    {
        'Service': 'First Class',
        'FirstClassMailType': 'LETTER',
        'ZipOrigination': '44106',
        'ZipDestination': '97217',
        'Pounds': '0',
        'Ounces': '3.5',
        'Size': 'REGULAR',
        'Machinable': 'true'
    },
    {
        'Service': 'Express',
        'ZipOrigination': '44106',
        'ZipDestination': '97217',
        'Pounds': '1',