本文整理汇总了Python中util.testpath函数的典型用法代码示例。如果您正苦于以下问题:Python testpath函数的具体用法?Python testpath怎么用?Python testpath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了testpath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_name
def test_name(self):
"""Parse affiliated org name"""
filings = list(lobbyists.parse_filings(util.testpath('affiliated_org_name.xml')))
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'E8A4D9C9-2D0B-4F0A-966D-A076858D2751')
orgs = x['affiliated_orgs']
o = orgs.pop()['org']
self.failUnlessEqual(o['name'], 'N/A')
self.failUnlessEqual(len(orgs), 0)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'C8293344-9A8D-4D6F-AAA5-25925E60BED9')
orgs = x['affiliated_orgs']
o = orgs.pop()['org']
self.failUnlessEqual(o['name'], 'CARITAS CHRISTI')
o = orgs.pop()['org']
self.failUnlessEqual(o['name'], 'BOSTON MEDICAL CENTER')
o = orgs.pop()['org']
self.failUnlessEqual(o['name'], 'PARTNERS HEALTHCARE SYSTEM')
o = orgs.pop()['org']
self.failUnlessEqual(o['name'], 'DANA FARBER CANCER INSTITUTE')
self.failUnlessEqual(len(orgs), 0)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '6D4AFEE6-E886-4993-B153-14A887FD325A')
orgs = x['affiliated_orgs']
o = orgs.pop()['org']
self.failUnlessEqual(o['name'], "Land O'Lakes, Inc.")
self.failUnlessEqual(len(filings), 0)
示例2: test_ownership_percentage
def test_ownership_percentage(self):
"""Parse foreign entity ownership percentage"""
filings = list(lobbyists.parse_filings(util.testpath('foreign_entity_ownership_percentage.xml')))
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '4CAC3894-FA4C-4CEC-99C7-1141544CA49B')
entities = x['foreign_entities']
e = entities.pop()['foreign_entity']
self.failUnlessEqual(e['ownership_percentage'], None)
e = entities.pop()['foreign_entity']
self.failUnlessEqual(e['ownership_percentage'], 100)
self.failUnlessEqual(len(entities), 0)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'E4382341-0E5D-4A31-8A7D-3CCB71E8EF6E')
entities = x['foreign_entities']
e = entities.pop()['foreign_entity']
self.failUnlessEqual(e['ownership_percentage'], 34)
self.failUnlessEqual(len(entities), 0)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'EEDBB5F5-8BB4-4E0D-9F10-CD8FDD2A0D70')
entities = x['foreign_entities']
e = entities.pop()['foreign_entity']
self.failUnlessEqual(e['ownership_percentage'], 0)
self.failUnlessEqual(len(entities), 0)
self.failUnlessEqual(len(filings), 0)
示例3: test_status
def test_status(self):
"""Parse lobbyist status"""
filings = list(lobbyists.parse_filings(util.testpath('lobbyist_status.xml')))
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '02DDA99B-725A-4DBA-8397-34892A6918D7')
lobbiers = x['lobbyists']
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['status'], 'terminated')
self.failUnlessEqual(len(lobbiers), 0)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'AB94AB3D-F5D6-4EE8-A462-0925A6D9A499')
lobbiers = x['lobbyists']
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['status'], 'active')
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['status'], 'terminated')
self.failUnlessEqual(len(lobbiers), 0)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '04926911-8A12-4A0E-9DA4-510869446EAC')
lobbiers = x['lobbyists']
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['status'], 'undetermined')
self.failUnlessEqual(len(lobbiers), 0)
self.failUnlessEqual(len(filings), 0)
示例4: test_status
def test_status(self):
"""Parse foreign entity status"""
filings = list(lobbyists.parse_filings(util.testpath('foreign_entity_status.xml')))
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '07361BD2-5007-42D6-8794-A7597AECC1B9')
entities = x['foreign_entities']
e = entities.pop()['foreign_entity']
self.failUnlessEqual(e['status'], 'undetermined')
self.failUnlessEqual(len(entities), 0)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '493C9C11-17ED-4875-88D2-FAC96FF06849')
entities = x['foreign_entities']
e = entities.pop()['foreign_entity']
self.failUnlessEqual(e['status'], 'terminated')
e = entities.pop()['foreign_entity']
self.failUnlessEqual(e['status'], 'terminated')
self.failUnlessEqual(len(entities), 0)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'BBF87FC8-73FC-4050-B6F8-850C79EC72E2')
entities = x['foreign_entities']
e = entities.pop()['foreign_entity']
self.failUnlessEqual(e['status'], 'active')
self.failUnlessEqual(len(entities), 0)
self.failUnlessEqual(len(filings), 0)
示例5: test_amount
def test_amount(self):
"""Parse filing amount"""
filings = list(lobbyists.parse_filings(util.testpath('amounts.xml')))
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'BAA88635-8674-4DF8-8825-2B0B3D8B4554')
self.failUnlessEqual(f['amount'], 108000)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '9648F901-BA48-4EE5-BE8B-01D5551BFDA1')
self.failUnlessEqual(f['amount'], 20000)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '8F21CC08-E136-4A42-A51D-25FE3B6CC303')
self.failUnlessEqual(f['amount'], 0)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'DE669D92-0620-4257-8B0C-01922EA0A226')
self.failUnlessEqual(f['amount'], None) # None means unspecified amount
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '5DA4C8F8-4E2D-4EE1-895C-00369A8222FB')
self.failUnlessEqual(f['amount'], None)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'DB4CCA2C-1E51-46A7-8800-00201697E905')
self.failUnlessEqual(f['amount'], None)
self.failUnlessEqual(len(filings), 0)
示例6: test_description
def test_description(self):
"""Parse client description"""
filings = list(lobbyists.parse_filings(util.testpath('client_description.xml')))
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'CCB41994-81FB-4C32-A155-082164564403')
client = x['client']
self.failUnlessEqual(client['description'], 'unspecified')
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'BD57AEBC-D1D7-4867-880E-0711F5AABD17')
client = x['client']
self.failUnlessEqual(client['description'], 'unspecified')
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '530238AB-4144-484F-8297-00D4A969779C')
client = x['client']
self.failUnlessEqual(client['description'], 'DISABILITY RESEARCH')
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '1402A175-987F-4896-B0F5-00107EF69834')
client = x['client']
self.failUnlessEqual(client['description'], 'Distributor of tactical clothing and gear for the military and law enforcement.')
self.failUnlessEqual(len(filings), 0)
示例7: test_import_foreign_entities_country
def test_import_foreign_entities_country(self):
"""Importing foreign entities should fill the 'country' table."""
filings = list(lobbyists.parse_filings(util.testpath('foreign_entities.xml')))
con = sqlite3.connect(':memory:')
con = lobbyists.create_db(con)
cur = con.cursor()
self.failUnless(lobbyists.import_filings(cur, filings))
con.row_factory = sqlite3.Row
cur = con.cursor()
cur.execute("SELECT * FROM country")
rows = [row for row in cur]
row = rows.pop()
self.failUnlessEqual(row['name'], 'AUSTRALIA')
row = rows.pop()
self.failUnlessEqual(row['name'], 'UNDETERMINED')
row = rows.pop()
self.failUnlessEqual(row['name'], 'SEYCHELLES')
row = rows.pop()
self.failUnlessEqual(row['name'], 'UNITED KINGDOM')
row = rows.pop()
self.failUnlessEqual(row['name'], '<SELECT ONE>')
row = rows.pop()
self.failUnlessEqual(row['name'], 'unspecified')
row = rows.pop()
self.failUnlessEqual(row['name'], 'USA')
row = rows.pop()
self.failUnlessEqual(row['name'], 'GERMANY')
row = rows.pop()
self.failUnlessEqual(row['name'], 'JAPAN')
self.failUnlessEqual(len(rows), 0)
示例8: test_name
def test_name(self):
"""Parse client name"""
filings = list(lobbyists.parse_filings(util.testpath('client_name.xml')))
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '5A4F7B14-D143-4B57-A345-34296865C20D')
client = x['client']
self.failUnlessEqual(client['name'], 'Microsoft')
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '357D6040-8761-42CB-94C9-0A27C088091E')
client = x['client']
self.failUnlessEqual(client['name'], 'COMPUTER & COMMUNICATIONS INDUSTRY ASSN')
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '240EDC03-05F3-4F04-9F4B-0018BF4651F1')
client = x['client']
self.failUnlessEqual(client['name'], 'AUTOMATIC DATA PROCESSING, INC.')
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '583E1BE3-1B7E-4357-A6C8-00125C7DE22D')
client = x['client']
self.failUnlessEqual(client['name'], 'EMPRESA BRASILEIRA DE AERONAUTICA SA (EMBRAER)')
self.failUnlessEqual(len(filings), 0)
示例9: test_import_affiliated_orgs_country
def test_import_affiliated_orgs_country(self):
"""Importing affiliated orgs should fill the 'country' table."""
filings = list(lobbyists.parse_filings(util.testpath('affiliated_orgs.xml')))
con = sqlite3.connect(':memory:')
con = lobbyists.create_db(con)
cur = con.cursor()
self.failUnless(lobbyists.import_filings(cur, filings))
con.row_factory = sqlite3.Row
cur = con.cursor()
cur.execute("SELECT * FROM country")
rows = [row for row in cur]
row = rows.pop()
self.failUnlessEqual(row['name'], 'PUERTO RICO')
row = rows.pop()
self.failUnlessEqual(row['name'], 'unspecified')
row = rows.pop()
self.failUnlessEqual(row['name'], 'UNITED KINGDOM')
row = rows.pop()
self.failUnlessEqual(row['name'], 'UNDETERMINED')
row = rows.pop()
self.failUnlessEqual(row['name'], '<SELECT ONE>')
row = rows.pop()
self.failUnlessEqual(row['name'], 'USA')
self.failUnlessEqual(len(rows), 0)
示例10: test_address
def test_address(self):
"""Parse registrant address"""
filings = list(lobbyists.parse_filings(util.testpath('registrant_addrs.xml')))
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'D3EEF6D2-FE0B-4A03-A633-AAA16C50BE89')
reg = x['registrant']
self.failUnlessEqual(reg['address'],
'Waterside P. O. Box 365\r\nHarmondworth, West Drayto\r\nBE\r\nBELGIUM')
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'D4AFC576-0B22-4CE7-B595-141BE8ABC8DC')
reg = x['registrant']
self.failUnlessEqual(reg['address'], 'unspecified')
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'CD6A4955-8D7B-44C4-A3E4-00603FAC03A3')
reg = x['registrant']
self.failUnlessEqual(reg['address'],
'101 Constitution Avenue, NW\r\nSuite 600 West\r\nWashington, DC 20001')
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'D97EF71E-9062-42A9-9510-00048B943421')
reg = x['registrant']
self.failUnlessEqual(reg['address'],
'8 HERBERT STREET\r\nALEXANDRIA, VA 22305')
self.failUnlessEqual(len(filings), 0)
示例11: test_import_registrants
def test_import_registrants(self):
"""Import registrants."""
filings = list(lobbyists.parse_filings(util.testpath('registrants.xml')))
con = sqlite3.connect(':memory:')
con = lobbyists.create_db(con)
cur = con.cursor()
self.failUnless(lobbyists.import_filings(cur, filings))
con.row_factory = sqlite3.Row
cur = con.cursor()
cur.execute("SELECT filing_registrant.filing AS filing_id, \
filing_registrant.address AS address, \
filing_registrant.description AS description, \
registrant.country AS country, \
registrant.senate_id AS senate_id, \
registrant.name AS name, \
registrant.ppb_country AS ppb_country \
FROM filing_registrant INNER JOIN registrant ON \
registrant.id=filing_registrant.registrant")
rows = [row for row in cur]
rows.sort(key=lambda x: x['filing_id'])
registrants = [x for x in filings if 'registrant' in x]
registrants.sort(key=lambda x: x['filing']['id'])
self.failUnlessEqual(len(rows), len(registrants))
for (row, filing) in zip(rows, registrants):
self.failUnlessEqual(row['filing_id'], filing['filing']['id'])
reg = filing['registrant']
self.failUnlessEqual(row['address'], reg['address'])
self.failUnlessEqual(row['description'], reg['description'])
self.failUnlessEqual(row['country'], reg['country'])
self.failUnlessEqual(row['senate_id'], reg['senate_id'])
self.failUnlessEqual(row['name'], reg['name'])
self.failUnlessEqual(row['ppb_country'], reg['ppb_country'])
示例12: test_description
def test_description(self):
"""Parse registrant description"""
filings = list(lobbyists.parse_filings(util.testpath('registrant_descriptions.xml')))
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'C35AF239-B3BF-45A8-A5F0-11B73F8C7D64')
reg = x['registrant']
self.failUnlessEqual(reg['description'],
u'Government Relations & Strategic Consulting')
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'D0325DF2-82F6-4FF1-8C72-08B9CC3E99D7')
reg = x['registrant']
self.failUnlessEqual(reg['description'],
'defense/energy/interior consulting')
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '443C63BC-F0DB-41F7-B912-002CABBF0CAD')
reg = x['registrant']
self.failUnlessEqual(reg['description'], 'unspecified')
self.failUnlessEqual(len(filings), 0)
示例13: test_official_position
def test_official_position(self):
"""Parse lobbyist 'official position'"""
filings = list(lobbyists.parse_filings(util.testpath('lobbyist_official_position.xml')))
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'AB94AB3D-F5D6-4EE8-A462-0925A6D9A499')
lobbiers = x['lobbyists']
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['official_position'], 'N/A')
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['official_position'],
'MGR. AIR TRAFFIC DIV. WEST PAC, REG, FAA')
self.failUnlessEqual(len(lobbiers), 0)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'BD894C51-AA23-46AE-9802-006B8C91702B')
lobbiers = x['lobbyists']
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['official_position'],
'ExecFlrAsst, H. Maj. Whip; ExecDir, H.DemCauc.')
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['official_position'],
'StaffAsst, DemPolicyComm; FlrAsst, MinoritySec')
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['official_position'],
'Chief of Staff, President Reagan')
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['official_position'],
'AsstEditor/Ed./Res.Dir, Sen.Rep.PolicyComm;')
self.failUnlessEqual(len(lobbiers), 0)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], 'DE038A45-9F6B-4764-B678-8004E7903BC4')
lobbiers = x['lobbyists']
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['official_position'], 'unspecified')
self.failUnlessEqual(len(lobbiers), 0)
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '2164D6BB-EBBA-40D2-9C18-16A2D670030A')
lobbiers = x['lobbyists']
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['official_position'], 'N/A')
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['official_position'], 'N/A')
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['official_position'], 'N/A')
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['official_position'], 'N/A')
l = lobbiers.pop()['lobbyist']
self.failUnlessEqual(l['official_position'], 'N/A')
self.failUnlessEqual(len(lobbiers), 0)
self.failUnlessEqual(len(filings), 0)
示例14: test_import_similar_registrants
def test_import_similar_registrants(self):
"""Slightly different registrants are inserted into different rows."""
filings = list(lobbyists.parse_filings(util.testpath('registrants_slightly_different.xml')))
con = sqlite3.connect(':memory:')
con = lobbyists.create_db(con)
cur = con.cursor()
self.failUnless(lobbyists.import_filings(cur, filings))
cur = con.cursor()
cur.execute('SELECT * FROM registrant')
self.failUnlessEqual(len(cur.fetchall()), len(filings))
示例15: test_senate_id
def test_senate_id(self):
"""Parse registrant Senate ID"""
filings = list(lobbyists.parse_filings(util.testpath('registrant_senate_id.xml')))
x = filings.pop()
f = x['filing']
self.failUnlessEqual(f['id'], '9CF0D039-7655-4C7E-99E9-00166359FD5B')
reg = x['registrant']
self.failUnlessEqual(reg['senate_id'], 287656)
self.failUnlessEqual(len(filings), 0)