Exemple #1
0
 def testAddressZip(self):
     addr1 = verify_by_usps.Address('', '', '', '', '123456789')
     self.assertEqual('12345', addr1.zip5)
     self.assertEqual('6789', addr1.zip4)
     addr1 = verify_by_usps.Address('', '', '', '', '12345-6789 ')
     self.assertEqual('12345', addr1.zip5)
     self.assertEqual('6789', addr1.zip4)
     addr1 = verify_by_usps.Address('', '', '', '', '12345')
     self.assertEqual('12345', addr1.zip5)
     self.assertEqual('0000', addr1.zip4)
     addr1 = verify_by_usps.Address('', '', '', '', '1234567')
     self.assertEqual('12345', addr1.zip5)
     self.assertEqual('6700', addr1.zip4)
     addr1 = verify_by_usps.Address('', '', '', '', '12')
     self.assertEqual('12000', addr1.zip5)
     self.assertEqual('0000', addr1.zip4)
     pass
    def testAddress(self):
        print('testAddress')
        for a in addresses:
            al = a.split(',')
            addr = verify_by_usps.Address(al[0], al[1], al[2], al[3], al[4])
            print(addr)
            va, msg = verify_by_usps.reqUSPS(addr)

            print(va)
            print(msg)
Exemple #3
0
def extractAddr(row, index):
    if len(row) >= max(index):
        a1 = row[index[0] - 1]
        a2 = row[index[1] - 1]
        c = row[index[2] - 1]
        s = row[index[3] - 1]
        p = row[index[4] - 1]
        row = row[index[5] - 1]
        return verify_by_usps.Address(a1, a2, c, s, p, row)
    else:
        return None
    def testRewriteAddrInfluenceUSPS(self):
        print('testRewriteAddrInfluenceUSPS')
        a = verify_by_usps.Address('1800 HARRISON ST FL 7', '', 'OAKLAND',
                                   'CA', '94612')
        v, msg = verify_by_usps.reqUSPS(a)
        self.assertEqual(
            ['1800 HARRISON ST FL 7', '', 'OAKLAND', 'CA', '94612'],
            [v.addr1, v.addr2, v.city, v.state, v.zip5])
        a = verify_by_usps.Address('1800 HARRISON ST', 'FL 7', 'OAKLAND', 'CA',
                                   '94612')
        v, msg = verify_by_usps.reqUSPS(a)
        self.assertEqual(
            ['1800 HARRISON ST FL 7', '', 'OAKLAND', 'CA', '94612'],
            [v.addr1, v.addr2, v.city, v.state, v.zip5])

        a = verify_by_usps.Address('3495 PIEDMONT RD NE BLDG 9', '', 'ATLANTA',
                                   'GA', '30305')
        v, msg = verify_by_usps.reqUSPS(a)
        print(msg)
        self.assertEqual(
            ['3495 PIEDMONT RD NE', 'BLDG 9', 'ATLANTA', 'GA', '30305'],
            [v.addr1, v.addr2, v.city, v.state, v.zip5])
        a = verify_by_usps.Address('3495 PIEDMONT RD NE', 'BLDG 9', 'ATLANTA',
                                   'GA', '30305')
        v, msg = verify_by_usps.reqUSPS(a)
        print(msg)
        self.assertEqual(
            ['3495 PIEDMONT RD NE', 'BLDG 9', 'ATLANTA', 'GA', '30305'],
            [v.addr1, v.addr2, v.city, v.state, v.zip5])

        a = verify_by_usps.Address('933 BRADBURY DR SE STE 2222', '',
                                   'ALBUQUERQUE', 'NM', '87106')
        v, msg = verify_by_usps.reqUSPS(a)
        print(msg)
        self.assertEqual(
            ['933 BRADBURY DR SE', 'STE 2222', 'ALBUQUERQUE', 'NM', '87106'],
            [v.addr1, v.addr2, v.city, v.state, v.zip5])
        a = verify_by_usps.Address('933 BRADBURY DR SE', 'STE 2222',
                                   'ALBUQUERQUE', 'NM', '87106')
        v, msg = verify_by_usps.reqUSPS(a)
        print(msg)
        self.assertEqual(
            ['933 BRADBURY DR SE', 'STE 2222', 'ALBUQUERQUE', 'NM', '87106'],
            [v.addr1, v.addr2, v.city, v.state, v.zip5])
        a = verify_by_usps.Address('STE 2222, 933 BRADBURY DR SE', '',
                                   'ALBUQUERQUE', 'NM', '87106')
        v, msg = verify_by_usps.reqUSPS(a)
        print(msg)
        self.assertIsNone(v)
    def testAddrWithFirmName(self):
        print('testAddrWithFirmName')
        #1818 ALBION ST,METROPOLITAN NASHVILLE GENERAL HOSPITAL EMERGENCY,NASHVILLE,TN,37208
        a = verify_by_usps.Address(
            '1818 ALBION ST',
            'METROPOLITAN NASHVILLE GENERAL HOSPITAL EMERGENCY', 'NASHVILLE',
            'TN', '37208')
        v, msg = verify_by_usps.reqUSPS(a)
        self.assertEqual([
            '1818 ALBION ST',
            'METROPOLITAN NASHVILLE GENERAL HOSPITAL EMERGENCY', 'NASHVILLE',
            'TN', '37208'
        ], [v.addr1, v.addr2, v.city, v.state, v.zip5])

        a = verify_by_usps.Address(
            'METROPOLITAN NASHVILLE GENERAL HOSPITAL EMERGENCY',
            '1818 ALBION ST', 'NASHVILLE', 'TN', '37208')
        v, msg = verify_by_usps.reqUSPS(a)
        self.assertEqual([
            '1818 ALBION ST',
            'METROPOLITAN NASHVILLE GENERAL HOSPITAL EMERGENCY', 'NASHVILLE',
            'TN', '37208'
        ], [v.addr1, v.addr2, v.city, v.state, v.zip5])

        a = verify_by_usps.Address('1818 ALBION ST', '', 'NASHVILLE', 'TN',
                                   '37208')
        v, msg = verify_by_usps.reqUSPS(a)
        self.assertEqual(['1818 ALBION ST', '', 'NASHVILLE', 'TN', '37208'],
                         [v.addr1, v.addr2, v.city, v.state, v.zip5])

        a = verify_by_usps.Address('', '1818 ALBION ST', 'NASHVILLE', 'TN',
                                   '37208')
        v, msg = verify_by_usps.reqUSPS(a)
        self.assertEqual(['1818 ALBION ST', '', 'NASHVILLE', 'TN', '37208'],
                         [v.addr1, v.addr2, v.city, v.state, v.zip5])

        a = verify_by_usps.Address(
            'METROPOLITAN NASHVILLE GENERAL HOSPITAL EMERGENCY', '',
            'NASHVILLE', 'TN', '37208')
        v, msg = verify_by_usps.reqUSPS(a)
        self.assertIsNone(v)

        a = verify_by_usps.Address(
            '', 'METROPOLITAN NASHVILLE GENERAL HOSPITAL EMERGENCY',
            'NASHVILLE', 'TN', '37208')
        v, msg = verify_by_usps.reqUSPS(a)
        self.assertIsNone(v)
Exemple #6
0
def createAddrFromRow(dbrow):
    vaddr = verify_by_usps.Address(dbrow[0], dbrow[1], dbrow[2], dbrow[3], dbrow[4] + dbrow[5]);
    oaddr = verify_by_usps.Address(dbrow[6], dbrow[7], dbrow[8], dbrow[9], dbrow[10] + dbrow[11], dbrow[12]);
    return vaddr, oaddr
 def testReplacePunctuation(self):
     addr = verify_by_usps.Address('500 OLD YORK ROAD', 'SUITE #108',
                                   'JENKINTOWN', 'PA', '19046')
     newaddr = addrMatch.replaceunctuation(addr)
     self.assertEqual('500 OLD YORK ROAD', newaddr.addr1)
     self.assertEqual('SUITE  108', newaddr.addr2)
Exemple #8
0
    nvf = open(nopassFile, 'wb')
    #nvf.write('' + '\n');
    with open(addressFile, 'rb') as csvfile:
        spamreader = csv.reader(csvfile, delimiter=',', quotechar='"')
        for row in spamreader:
            if spamreader.line_num <= beginline:
                continue
            if len(row) < max(indexs):
                break

            lex = verify_by_usps.AddressLexical(row[indexs[0] - 1],
                                                row[indexs[1] - 1])
            #print lex.__str__()
            #addr = verify_by_usps.Address(lex.primary[0], ' '.join(lex.secondary), row[indexs[2]  - 1], row[indexs[3]  -1], row[indexs[4]  - 1]);
            addr = verify_by_usps.Address(lex.primary[0], '',
                                          row[indexs[2] - 1],
                                          row[indexs[3] - 1],
                                          row[indexs[4] - 1])
            #print addr.__str__()
            #print spamreader.line_num, ': ', addr;
            if addr.isEmpty():
                print('')
                print('Empty:')
                print(', '.join(row))
                countEmpty += 1
                continue
            if addr.isForeign():
                print('')
                print('Foreign:')
                print(', '.join(row))
                countForeign += 1
                continue