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)
 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)
    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)
Пример #4
0
    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'])
Пример #5
0
    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)
Пример #6
0
 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))
Пример #7
0
 def test_import_identical_clients(self):
     """Identical clients shouldn't be duplicated in the database."""
     filings = list(lobbyists.parse_filings(util.testpath('clients_dup.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 client FROM filing_client')
     row1, row2 = cur.fetchall()
     self.failUnlessEqual(row1[0], row2[0])
Пример #8
0
 def test_import_similar_lobbyists(self):
     """Slightly different lobbyists are inserted into different rows."""
     filings = list(lobbyists.parse_filings(util.testpath('lobbyists_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 id FROM lobbyist')
     lobbyers = util.flatten([x['lobbyists'] for x in filings if 'lobbyists' in x])
     self.failUnlessEqual(len(cur.fetchall()), len(lobbyers))
 def test_import_foreign_entity_different_ownership(self):
     """Foreign entities with different percentage ownership but otherwise identical should occupy same row"""
     filings = list(lobbyists.parse_filings(util.testpath('foreign_entities_different_ownership.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 foreign_entity")
     rows = [row for row in cur]
     self.failUnlessEqual(len(rows), 1)
Пример #10
0
    def test_import_client_different_description(self):
        """Clients with different description but otherwise identical should occupy same row."""
        filings = list(lobbyists.parse_filings(util.testpath('clients_different_description.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 client")
        rows = [row for row in cur]
        self.failUnlessEqual(len(rows), 1)
Пример #11
0
 def test_import_similar_affiliated_orgs(self):
     """Slightly different affiliated orgs are inserted into different rows."""
     filings = list(
         lobbyists.parse_filings(
             util.testpath('affiliated_orgs_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 id FROM affiliated_org')
     orgs = util.flatten(
         [x['affiliated_orgs'] for x in filings if 'affiliated_orgs' in x])
     self.failUnlessEqual(len(cur.fetchall()), len(orgs))
 def test_import_foreign_entity_different_ownership(self):
     """Foreign entities with different percentage ownership but otherwise identical should occupy same row"""
     filings = list(
         lobbyists.parse_filings(
             util.testpath('foreign_entities_different_ownership.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 foreign_entity")
     rows = [row for row in cur]
     self.failUnlessEqual(len(rows), 1)
Пример #13
0
 def test_import_client_state_or_local_gov(self):
     """After importing clients, state_or_local_gov table should be unchanged (it's pre-loaded)."""
     filings = list(lobbyists.parse_filings(util.testpath('clients.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 val FROM state_or_local_gov")
     rows = set([row[0] for row in cur])
     self.failUnlessEqual(len(rows), 3)
     self.failUnless('unspecified' in rows)
     self.failUnless('y' in rows)
     self.failUnless('n' in rows)
Пример #14
0
 def test_import_client_client_status(self):
     """After importing clients, client_status table should be unchanged (it's pre-loaded)."""
     filings = list(lobbyists.parse_filings(util.testpath('clients.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 status FROM client_status")
     rows = set([row[0] for row in cur])
     self.failUnlessEqual(len(rows), 3)
     self.failUnless('active' in rows)
     self.failUnless('terminated' in rows)
     self.failUnless('administratively terminated' in rows)
Пример #15
0
 def test_import_identical_lobbyists2(self):
     """Identical lobbyists shouldn't be duplicated in the database (case 2)."""
     # This test file contains a single filing with two
     # lobbyists. The two lobbyists are exactly the same, except
     # with different statuses. This should result in only a single
     # entry in the filing_lobbyists table.
     filings = list(lobbyists.parse_filings(util.testpath('lobbyists_dup2.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 lobbyist')
     rows = cur.fetchall()
     self.failUnlessEqual(len(rows), 1)
 def test_import_identical_lobbyists2(self):
     """Identical lobbyists shouldn't be duplicated in the database (case 2)."""
     # This test file contains a single filing with two
     # lobbyists. The two lobbyists are exactly the same, except
     # with different statuses. This should result in only a single
     # entry in the filing_lobbyists table.
     filings = list(
         lobbyists.parse_filings(util.testpath('lobbyists_dup2.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 lobbyist')
     rows = cur.fetchall()
     self.failUnlessEqual(len(rows), 1)
Пример #17
0
    def test_import_lobbyist_person(self):
        """Importing lobbyists should fill the 'person' table."""
        filings = list(lobbyists.parse_filings(util.testpath('lobbyists.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 person")
        rows = [row['name'] for row in cur]
        lobbyers = util.flatten([x['lobbyists'] for x in filings if 'lobbyists' in x])
        names = set([x['lobbyist']['name'] for x in lobbyers])
        self.failUnlessEqual(len(rows), len(names))
        for name in names:
            self.failUnless(name in rows)
Пример #18
0
    def test_import_govt_entities(self):
        """Government entity importing."""
        filings = list(
            lobbyists.parse_filings(util.testpath('govt_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 govt_entity")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'UNDETERMINED')

        row = rows.pop()
        self.failUnlessEqual(row['name'],
                             'Federal Communications Commission (FCC)')

        row = rows.pop()
        self.failUnlessEqual(row['name'],
                             'Environmental Protection Agency (EPA)')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Energy, Dept of')

        row = rows.pop()
        self.failUnlessEqual(row['name'],
                             'Federal Energy Regulatory Commission (FERC)')

        row = rows.pop()
        self.failUnlessEqual(row['name'],
                             'Health & Human Services, Dept of  (HHS)')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'SENATE')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'HOUSE OF REPRESENTATIVES')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'NONE')

        self.failUnlessEqual(len(rows), 0)
Пример #19
0
    def test_import_client_orgs(self):
        """Importing clients should fill the 'org' table."""
        filings = list(lobbyists.parse_filings(util.testpath('clients.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 org")
        rows = [row['name'] for row in cur]
        clients = [x for x in filings if 'client' in x]
        orgs = set([x['client']['name'] for x in clients])
        self.failUnlessEqual(len(rows), len(orgs))
        for org in orgs:
            self.failUnless(org in rows)
Пример #20
0
    def test_import_govt_entities(self):
        """Government entity importing."""
        filings = list(lobbyists.parse_filings(util.testpath('govt_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 govt_entity")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'UNDETERMINED')

        row = rows.pop()
        self.failUnlessEqual(row['name'],
                             'Federal Communications Commission (FCC)')

        row = rows.pop()
        self.failUnlessEqual(row['name'],
                             'Environmental Protection Agency (EPA)')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Energy, Dept of')

        row = rows.pop()
        self.failUnlessEqual(row['name'],
                             'Federal Energy Regulatory Commission (FERC)')

        row = rows.pop()
        self.failUnlessEqual(row['name'],
                             'Health & Human Services, Dept of  (HHS)')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'SENATE')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'HOUSE OF REPRESENTATIVES')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'NONE')

        self.failUnlessEqual(len(rows), 0)
    def test_import_lobbyist_person(self):
        """Importing lobbyists should fill the 'person' table."""
        filings = list(lobbyists.parse_filings(util.testpath('lobbyists.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 person")
        rows = [row['name'] for row in cur]
        lobbyers = util.flatten(
            [x['lobbyists'] for x in filings if 'lobbyists' in x])
        names = set([x['lobbyist']['name'] for x in lobbyers])
        self.failUnlessEqual(len(rows), len(names))
        for name in names:
            self.failUnless(name in rows)
Пример #22
0
    def test_import_registrant_countries(self):
        """Importing registrants fills the 'country' table."""
        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 * FROM country")
        rows = [row['name'] for row in cur]
        registrants = [x for x in filings if 'registrant' in x]
        countries = set([x['registrant']['country'] for x in registrants])
        countries = countries.union([x['registrant']['ppb_country'] for x in \
                                         registrants])
        self.failUnlessEqual(len(rows), len(countries))
        for country in countries:
            self.failUnless(country in rows)
 def test_import_foreign_entities_org(self):
     """Importing foreign entities should fill the 'org' 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 org")
     rows = [row for row in cur]
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'THE NEWS CORPORATION LTD.')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'EMBASSY OF VENEZUELA')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'Japan Tobacco Inc.')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'N/A')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'WALLETTE, GERALD')
     row = rows.pop()
     self.failUnlessEqual(row['name'],
                          'CITIZENS FOR DEMOCRACTIC RULE IN NIGERIA')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'Beta Gamma Ltd.')
     row = rows.pop()
     self.failUnlessEqual(row['name'], "FBC Group Ltd.")
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'AgustaWestland Holdings, Ltd.')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'HITACHI, LTD.')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'EVONIK INDUSTRIES GMBH')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'MARUHA CORP')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'HOKO FISHING CO')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'NORTH JAPAN MARITIME CORP')
     self.failUnlessEqual(len(rows), 0)
Пример #24
0
    def test_import_clients(self):
        """Import clients."""
        filings = list(lobbyists.parse_filings(util.testpath('clients.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_client.filing AS filing_id, \
                            client.country AS country, \
                            filing_client.senate_id as senate_id, \
                            client.name as name, \
                            client.ppb_country as ppb_country, \
                            client.state as state, \
                            client.ppb_state as ppb_state, \
                            filing_client.status as status, \
                            filing_client.description as description, \
                            client.state_or_local_gov as state_or_local_gov, \
                            filing_client.contact_name as contact_name \
                     FROM filing_client INNER JOIN client ON \
                            client.id=filing_client.client")
        rows = [row for row in cur]
        rows.sort(key=lambda x: x['filing_id'])
        clients = [x for x in filings if 'client' in x]
        clients.sort(key=lambda x: x['filing']['id'])
        self.failUnlessEqual(len(rows), len(clients))
        for (row, filing) in zip(rows, clients):
            self.failUnlessEqual(row['filing_id'], filing['filing']['id'])
            client = filing['client']
            self.failUnlessEqual(row['country'], client['country'])
            self.failUnlessEqual(row['senate_id'], client['senate_id'])
            self.failUnlessEqual(row['name'], client['name'])
            self.failUnlessEqual(row['ppb_country'], client['ppb_country'])
            self.failUnlessEqual(row['state'], client['state'])
            self.failUnlessEqual(row['ppb_state'], client['ppb_state'])
            self.failUnlessEqual(row['status'], client['status'])
            self.failUnlessEqual(row['description'], client['description'])
            self.failUnlessEqual(row['state_or_local_gov'], client['state_or_local_gov'])
            self.failUnlessEqual(row['contact_name'], client['contact_name'])
 def test_import_foreign_entities_org(self):
     """Importing foreign entities should fill the 'org' 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 org")
     rows = [row for row in cur]
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'THE NEWS CORPORATION LTD.')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'EMBASSY OF VENEZUELA')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'Japan Tobacco Inc.')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'N/A')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'WALLETTE, GERALD')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'CITIZENS FOR DEMOCRACTIC RULE IN NIGERIA')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'Beta Gamma Ltd.')
     row = rows.pop()
     self.failUnlessEqual(row['name'], "FBC Group Ltd.")
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'AgustaWestland Holdings, Ltd.')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'HITACHI, LTD.')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'EVONIK INDUSTRIES GMBH')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'MARUHA CORP')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'HOKO FISHING CO')
     row = rows.pop()
     self.failUnlessEqual(row['name'], 'NORTH JAPAN MARITIME CORP')
     self.failUnlessEqual(len(rows), 0)
Пример #26
0
    def test_import_filings(self):
        """Import filings"""
        filings = list(lobbyists.parse_filings(util.testpath('filings.xml')))
        con = sqlite3.connect(':memory:')
        con = lobbyists.create_db(con)
        cur = con.cursor()
        self.failUnless(lobbyists.import_filings(cur, filings))

        # Read back, sort and compare
        con.row_factory = sqlite3.Row
        cur = con.cursor()
        cur.execute("SELECT * FROM filing")
        rows = [row for row in cur]
        rows.sort(key=lambda x: x['id'])
        filings.sort(key=lambda x: x['filing']['id'])

        self.failUnlessEqual(len(rows), len(filings))
        for (row, filing) in zip(rows, filing_values(filings)):
            self.failUnlessEqual(row['id'], filing['id'])
            self.failUnlessEqual(row['type'], filing['type'])
            self.failUnlessEqual(row['year'], filing['year'])
            self.failUnlessEqual(row['period'], filing['period'])
            self.failUnlessEqual(row['filing_date'], filing['filing_date'])
            self.failUnlessEqual(row['amount'], filing['amount'])
Пример #27
0
    def test_import_issues(self):
        """Import issues"""
        filings = list(lobbyists.parse_filings(util.testpath('issues.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 issue")
        rows = list(cur)

        row = rows.pop()
        self.failUnlessEqual(row['id'], 23)
        self.failUnlessEqual(row['code'], 'ENERGY/NUCLEAR')
        self.failUnlessEqual(row['specific_issue'],
                             '\r\nComprehensive Energy Bill')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 22)
        self.failUnlessEqual(row['code'], 'TRANSPORTATION')
        self.failUnlessEqual(
            row['specific_issue'],
            '\r\nH.R. 1495 Water Resources Development Act (WRDA) - the WRDA provisions to modernize the locks on the Upper Mississippi and Illinois Rivers are essential if U.S. agriculture is going to remain competitive in the global marketplace.\r\nH.R. 1495 the Water Resources Development Act of 2007 (WRDA) - conference report - Title VIII of the legislation includes authorization for the Corps of Engineers to construct new 1,200 foot locks on the Upper Mississippi and Illinois Rivers\n'
        )

        row = rows.pop()
        self.failUnlessEqual(row['id'], 21)
        self.failUnlessEqual(row['code'], 'IMMIGRATION')
        self.failUnlessEqual(
            row['specific_issue'],
            '\r\nImmigration - Thanking Senator Lincoln and her staff for the hard work and long hours and dedication they presented in an effort to develop a comprehensive immigration reform.\n'
        )

        row = rows.pop()
        self.failUnlessEqual(row['id'], 20)
        self.failUnlessEqual(row['code'], 'AGRICULTURE')
        self.failUnlessEqual(
            row['specific_issue'],
            '\r\nFY08 Agriculture Appropriations Bill - (Sec. 738) amendment to prohibit USDA from spending money for health inspection of horses.\n\nH.R. 3161, the FY08 Ag spending bill - amendments: King/Kingston amendment to strike Sec. 738. It would limit USDA authority for equine health inspection, effectively restricting the movement of all horses; Ackerman amendment prohibits funding for Food Safety and Inspection Service (FSIS) inspections in facilities that process nonambulatory or downer livestock;  Whitfield-Spratt-Rahall-Chandler amendment to restrict USDA inspection of horses intended for processing for human consumption.\n\nPayment Limits.\r\nFarm Bill: tax title, reductions in direct payments, counter-cyclical revenue option, senate ag committee markup on farm bill, amendments seeking further reform to payment limits and adjusted gross income restrictions.\n'
        )

        row = rows.pop()
        self.failUnlessEqual(row['id'], 19)
        self.failUnlessEqual(row['code'], 'TRADE (DOMESTIC/FOREIGN)')
        self.failUnlessEqual(
            row['specific_issue'],
            '\r\nU.S. -Peru Trade Promotion Agreement (TPA) - the goal is to increase U.S. agriculture exports and increase market share.'
        )

        row = rows.pop()
        self.failUnlessEqual(row['id'], 18)
        self.failUnlessEqual(row['code'], 'EDUCATION')
        self.failUnlessEqual(
            row['specific_issue'],
            '\r\nFY08 Labor, HHS and Education spending.  Perkins Amendment (federal funding for FFA and career and technical education).'
        )

        row = rows.pop()
        self.failUnlessEqual(row['id'], 17)
        self.failUnlessEqual(row['code'], 'ROADS/HIGHWAY')
        self.failUnlessEqual(
            row['specific_issue'],
            '\r\nH.R. 3098 to restore farm truck exemptions from federal motor carrier vehicle regulations.'
        )

        row = rows.pop()
        self.failUnlessEqual(row['id'], 16)
        self.failUnlessEqual(row['code'], 'DEFENSE')
        self.failUnlessEqual(
            row['specific_issue'],
            'H.R.3222 & Senate FY08 Defense Appropriations-Navy, Army & SOCOM R&D\nH.R.1585 & S.1547 FY08 Defense Authorizations-Navy, Army & SOCOM R&D\n'
        )

        row = rows.pop()
        self.failUnlessEqual(row['id'], 15)
        self.failUnlessEqual(row['code'], 'HOMELAND SECURITY')
        self.failUnlessEqual(
            row['specific_issue'],
            'H.R.3222 & Senate FY08 Defense Appropriations-Navy, Army & SOCOM R&D\nH.R.1585 & S.1547 FY08 Defense Authorizations-Navy, Army & SOCOM R&D\nH.R.2638 & S.1644 FY08 DHS AppropriationsBill-CRP'
        )

        row = rows.pop()
        self.failUnlessEqual(row['id'], 14)
        self.failUnlessEqual(row['code'], 'BUDGET/APPROPRIATIONS')
        self.failUnlessEqual(
            row['specific_issue'],
            'H.R.3222 & Senate FY08 Defense Appropriations-Navy, Army & SOCOM R&D\nH.R.1585 & S.1547 FY08 Defense Authorizations-Navy, Army & SOCOM R&D\nH.R.2638 & S.1644 FY08 DHS AppropriationsBill-CRP'
        )

        row = rows.pop()
        self.failUnlessEqual(row['id'], 13)
        self.failUnlessEqual(row['code'], 'DEFENSE')
        self.failUnlessEqual(
            row['specific_issue'],
            'DEFENSE AUTHORIZATION, DEFENSE APPROPRIATIONS, VETERANS, DEFENSE HEALTH CARE, ARMED FORCES RETIREMENT, ARMED FORCES PERSONNEL BENEFITS, EMERGING DEFENSE RELATED ISSUES'
        )

        row = rows.pop()
        self.failUnlessEqual(row['id'], 12)
        self.failUnlessEqual(row['code'], 'BANKING')
        self.failUnlessEqual(row['specific_issue'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 11)
        self.failUnlessEqual(row['code'], 'REAL ESTATE/LAND USE/CONSERVATION')
        self.failUnlessEqual(row['specific_issue'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 10)
        self.failUnlessEqual(row['code'],
                             'FINANCIAL INSTITUTIONS/INVESTMENTS/SECURITIES')
        self.failUnlessEqual(row['specific_issue'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 9)
        self.failUnlessEqual(row['code'], 'FOREIGN RELATIONS')
        self.failUnlessEqual(row['specific_issue'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 8)
        self.failUnlessEqual(row['code'],
                             'LAW ENFORCEMENT/CRIME/CRIMINAL JUSTICE')
        self.failUnlessEqual(row['specific_issue'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 7)
        self.failUnlessEqual(row['code'], 'FAMILY ISSUES/ABORTION/ADOPTION')
        self.failUnlessEqual(row['specific_issue'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 6)
        self.failUnlessEqual(row['code'], 'HEALTH ISSUES')
        self.failUnlessEqual(row['specific_issue'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 5)
        self.failUnlessEqual(row['code'], 'MEDICARE/MEDICAID')
        self.failUnlessEqual(row['specific_issue'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 4)
        self.failUnlessEqual(row['code'], 'WELFARE')
        self.failUnlessEqual(row['specific_issue'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 3)
        self.failUnlessEqual(row['code'], 'BUDGET/APPROPRIATIONS')
        self.failUnlessEqual(row['specific_issue'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 2)
        self.failUnlessEqual(row['code'], 'TAXATION/INTERNAL REVENUE CODE')
        self.failUnlessEqual(row['specific_issue'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 1)
        self.failUnlessEqual(row['code'], 'INSURANCE')
        self.failUnlessEqual(row['specific_issue'], 'unspecified')

        self.failUnlessEqual(len(rows), 0)
    def test_import_filing_to_foreign_entities(self):
        """Foreign entities are matched up with filings in the database."""
        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 filing_foreign_entities")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'E4382341-0E5D-4A31-8A7D-3CCB71E8EF6E')
        self.failUnlessEqual(row['contribution'], 0)
        self.failUnlessEqual(row['ownership_percentage'], 34)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 16)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'EEDBB5F5-8BB4-4E0D-9F10-CD8FDD2A0D70')
        self.failUnlessEqual(row['contribution'], 100000)
        self.failUnlessEqual(row['ownership_percentage'], 0)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 15)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BBF87FC8-73FC-4050-B6F8-850C79EC72E2')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], 100)
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['foreign_entity'], 14)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'CE714D21-6713-4764-87F2-5F6294F0FBB3')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 13)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'CE714D21-6713-4764-87F2-5F6294F0FBB3')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'terminated')
        self.failUnlessEqual(row['foreign_entity'], 12)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BECA0C94-4308-47E5-BF23-887D3954E254')
        self.failUnlessEqual(row['contribution'], 0)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 11)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BECA0C94-4308-47E5-BF23-887D3954E254')
        self.failUnlessEqual(row['contribution'], 0)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 10)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BECA0C94-4308-47E5-BF23-887D3954E254')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 9)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '4CAC3894-FA4C-4CEC-99C7-1141544CA49B')
        self.failUnlessEqual(row['contribution'], 300000)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['foreign_entity'], 8)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '4CAC3894-FA4C-4CEC-99C7-1141544CA49B')
        self.failUnlessEqual(row['contribution'], 300000)
        self.failUnlessEqual(row['ownership_percentage'], 100)
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['foreign_entity'], 7)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '63AC4585-74BC-478D-A356-FCCFD98FDE64')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], 100)
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['foreign_entity'], 6)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '498EAE8A-DE7A-4FFF-A813-062D92FDA271')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], 100)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 5)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'ACD87507-EB78-4607-95E8-43871D9D1EF2')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], 100)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 4)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A9F81F8B-F0B0-440A-8564-051FF553CCA8')
        self.failUnlessEqual(row['contribution'], 0)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 3)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A9F81F8B-F0B0-440A-8564-051FF553CCA8')
        self.failUnlessEqual(row['contribution'], 16500)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 2)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A9F81F8B-F0B0-440A-8564-051FF553CCA8')
        self.failUnlessEqual(row['contribution'], 16500)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 1)

        self.failUnlessEqual(len(rows), 0)
Пример #29
0
    def test_import_issues_issue_code(self):
        """Importing issues should fill issue_code table."""
        filings = list(lobbyists.parse_filings(util.testpath('issues.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 issue_code")
        rows = list(cur)

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'ENERGY/NUCLEAR')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'TRANSPORTATION')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'IMMIGRATION')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'AGRICULTURE')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'TRADE (DOMESTIC/FOREIGN)')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'EDUCATION')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'ROADS/HIGHWAY')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'HOMELAND SECURITY')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'DEFENSE')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'BANKING')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'REAL ESTATE/LAND USE/CONSERVATION')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'FINANCIAL INSTITUTIONS/INVESTMENTS/SECURITIES')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'FOREIGN RELATIONS')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'LAW ENFORCEMENT/CRIME/CRIMINAL JUSTICE')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'FAMILY ISSUES/ABORTION/ADOPTION')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'HEALTH ISSUES')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'MEDICARE/MEDICAID')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'WELFARE')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'BUDGET/APPROPRIATIONS')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'TAXATION/INTERNAL REVENUE CODE')

        row = rows.pop()
        self.failUnlessEqual(row['code'], 'INSURANCE')

        self.failUnlessEqual(len(rows), 0)
Пример #30
0
    def test_import_filings_to_lobbyists(self):
        """Lobbyists are matched up with filings in the database."""
        filings = list(lobbyists.parse_filings(util.testpath('lobbyists.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 filing_lobbyists")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '771F3B6A-315D-4190-88F3-2CE0F138B2B8')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 16)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '771F3B6A-315D-4190-88F3-2CE0F138B2B8')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 15)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BD894C51-AA23-46AE-9802-006B8C91702B')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 14)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BD894C51-AA23-46AE-9802-006B8C91702B')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 13)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BD894C51-AA23-46AE-9802-006B8C91702B')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 12)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BD894C51-AA23-46AE-9802-006B8C91702B')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 11)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '2164D6BB-EBBA-40D2-9C18-16A2D670030A')
        self.failUnlessEqual(row['status'], 'terminated')
        self.failUnlessEqual(row['lobbyist'], 10)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '87A30FA6-7C35-4294-BA43-4CE7B5B808B3')
        self.failUnlessEqual(row['status'], 'terminated')
        self.failUnlessEqual(row['lobbyist'], 9)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '0FC23296-F948-43FD-98D4-0912F6579E6A')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 8)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '0FC23296-F948-43FD-98D4-0912F6579E6A')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 7)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '0FC23296-F948-43FD-98D4-0912F6579E6A')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 6)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '02DDA99B-725A-4DBA-8397-34892A6918D7')
        self.failUnlessEqual(row['status'], 'terminated')
        self.failUnlessEqual(row['lobbyist'], 5)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '02DDA99B-725A-4DBA-8397-34892A6918D7')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 4)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '02DDA99B-725A-4DBA-8397-34892A6918D7')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 3)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '02DDA99B-725A-4DBA-8397-34892A6918D7')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 2)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '04926911-8A12-4A0E-9DA4-510869446EAC')
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['lobbyist'], 1)
    def test_import_foreign_entities(self):
        """Import foreign entities"""
        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 foreign_entity")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['id'], 16)
        self.failUnlessEqual(row['name'], 'THE NEWS CORPORATION LTD.')
        self.failUnlessEqual(row['country'], 'UNDETERMINED')
        self.failUnlessEqual(row['ppb_country'], 'AUSTRALIA')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 15)
        self.failUnlessEqual(row['name'], 'EMBASSY OF VENEZUELA')
        self.failUnlessEqual(row['country'], 'UNDETERMINED')
        self.failUnlessEqual(row['ppb_country'], 'USA')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 14)
        self.failUnlessEqual(row['name'], 'Japan Tobacco Inc.')
        self.failUnlessEqual(row['country'], 'JAPAN')
        self.failUnlessEqual(row['ppb_country'], 'JAPAN')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 13)
        self.failUnlessEqual(row['name'], 'N/A')
        self.failUnlessEqual(row['country'], 'USA')
        self.failUnlessEqual(row['ppb_country'], 'UNDETERMINED')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 12)
        self.failUnlessEqual(row['name'], 'N/A')
        self.failUnlessEqual(row['country'], 'UNDETERMINED')
        self.failUnlessEqual(row['ppb_country'], 'UNDETERMINED')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 11)
        self.failUnlessEqual(row['name'], 'WALLETTE, GERALD')
        self.failUnlessEqual(row['country'], 'USA')
        self.failUnlessEqual(row['ppb_country'], 'USA')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 10)
        self.failUnlessEqual(row['name'], 'CITIZENS FOR DEMOCRACTIC RULE IN NIGERIA')
        self.failUnlessEqual(row['country'], 'USA')
        self.failUnlessEqual(row['ppb_country'], 'USA')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 9)
        self.failUnlessEqual(row['name'], 'CITIZENS FOR DEMOCRACTIC RULE IN NIGERIA')
        self.failUnlessEqual(row['country'], 'UNDETERMINED')
        self.failUnlessEqual(row['ppb_country'], 'UNDETERMINED')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 8)
        self.failUnlessEqual(row['name'], 'Beta Gamma Ltd.')
        self.failUnlessEqual(row['country'], 'SEYCHELLES')
        self.failUnlessEqual(row['ppb_country'], 'SEYCHELLES')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 7)
        self.failUnlessEqual(row['name'], "FBC Group Ltd.")
        self.failUnlessEqual(row['country'], 'UNITED KINGDOM')
        self.failUnlessEqual(row['ppb_country'], 'UNITED KINGDOM')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 6)
        self.failUnlessEqual(row['name'], 'AgustaWestland Holdings, Ltd.')
        self.failUnlessEqual(row['country'], '<SELECT ONE>')
        self.failUnlessEqual(row['ppb_country'], '<SELECT ONE>')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 5)
        self.failUnlessEqual(row['name'], 'HITACHI, LTD.')
        self.failUnlessEqual(row['country'], 'unspecified')
        self.failUnlessEqual(row['ppb_country'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 4)
        self.failUnlessEqual(row['name'], 'EVONIK INDUSTRIES GMBH')
        self.failUnlessEqual(row['country'], 'GERMANY')
        self.failUnlessEqual(row['ppb_country'], 'USA')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 3)
        self.failUnlessEqual(row['name'], 'MARUHA CORP')
        self.failUnlessEqual(row['country'], 'JAPAN')
        self.failUnlessEqual(row['ppb_country'], 'JAPAN')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 2)
        self.failUnlessEqual(row['name'], 'HOKO FISHING CO')
        self.failUnlessEqual(row['country'], 'JAPAN')
        self.failUnlessEqual(row['ppb_country'], 'JAPAN')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 1)
        self.failUnlessEqual(row['name'], 'NORTH JAPAN MARITIME CORP')
        self.failUnlessEqual(row['country'], 'JAPAN')
        self.failUnlessEqual(row['ppb_country'], 'JAPAN')

        self.failUnlessEqual(len(rows), 0)
Пример #32
0
    def test_import_affiliated_orgs_org(self):
        """Importing affiliated orgs should fill the 'org' 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 org")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'PORTAL DEL FUTURO AUTHORITY')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'ITNL EMISSIONS TRADING ASSN')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'ISL')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'CHILDRENS HOSPITAL OAKLAND')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'INMARSAT LTD')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'UC GROUP LIMITED')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'N/A')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Time Warner Cable')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Palm, Inc.')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Warner Bros.')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'AOL')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Power Pyles Sutter & Verville')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Holland and Knight')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'HCR ManorCare')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Vitas')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Odyssey')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'AseraCare')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'UT-Battelle')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Brookhaven Science Association')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Ross Stores, Inc.')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Wal-Mart Stores, Inc.')

        row = rows.pop()
        self.failUnlessEqual(row['name'], "Land O'Lakes, Inc.")

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'SOUTHEASTERN FEDERAL POWER CUSTOME')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Patton Boggs, LLP')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'CARITAS CHRISTI')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'BOSTON MEDICAL CENTER')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'PARTNERS HEALTHCARE SYSTEM')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'DANA FARBER CANCER INSTITUTE')

        row = rows.pop()
        self.failUnlessEqual(row['name'],
                             'ORANGE COUNTY TRANSPORTATION AUTHOR')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'JERRY REDDEN')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'EXXONMOBILE')

        self.failUnlessEqual(len(rows), 0)
Пример #33
0
    def test_import_affiliated_org_urls(self):
        """Importing affiliated orgs should fill the 'url' 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 url")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['url'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['url'],
                             "are the members listed on coalition's website?")

        row = rows.pop()
        self.failUnlessEqual(row['url'], 'www.hklaw.com    www.ppsv.com')

        row = rows.pop()
        self.failUnlessEqual(
            row['url'],
            'www.vitas.com, www.odyssey-healthcare.com, www.hcr-manorcare.com/home, www.aseracare.com'
        )

        row = rows.pop()
        self.failUnlessEqual(
            row['url'],
            'www.bnl.gov (Brookhaven Science Association);   www.ut-battelle.org (UT-Battelle)'
        )

        row = rows.pop()
        self.failUnlessEqual(row['url'],
                             'www.wal-mart.com; www.rossstores.com')

        row = rows.pop()
        self.failUnlessEqual(
            row['url'],
            'www.landolakesinc.com              4001 Lexington Ave. N, Arden Hills Minnesota 55112-6943'
        )

        row = rows.pop()
        self.failUnlessEqual(row['url'], 'None')

        row = rows.pop()
        self.failUnlessEqual(
            row['url'],
            'Patton Boggs, LLP, 2550 M. Street N.W., Washington, D.C. 20037 - [email protected]'
        )

        row = rows.pop()
        self.failUnlessEqual(row['url'], 'N/A')

        row = rows.pop()
        self.failUnlessEqual(row['url'], '*****@*****.**')

        row = rows.pop()
        self.failUnlessEqual(
            row['url'], 'http://skipjack.net/le_shore/worcestr/welcome.html')

        row = rows.pop()
        self.failUnlessEqual(row['url'], 'www.exxonmobile.com')

        self.failUnlessEqual(len(rows), 0)
Пример #34
0
    def test_import_filings_to_govt_entities(self):
        """Government entities are matched up with filings in the database."""
        filings = list(lobbyists.parse_filings(util.testpath('govt_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 filing_govt_entities")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '2627E811-33AB-43F4-B8E0-5B979A10FBF9')
        self.failUnlessEqual(row['govt_entity'], 'UNDETERMINED')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '106C2C6E-F0E1-46E3-9409-294E0BD27878')
        self.failUnlessEqual(row['govt_entity'],
                             'Federal Communications Commission (FCC)')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '106C2C6E-F0E1-46E3-9409-294E0BD27878')
        self.failUnlessEqual(row['govt_entity'],
                             'Environmental Protection Agency (EPA)')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '106C2C6E-F0E1-46E3-9409-294E0BD27878')
        self.failUnlessEqual(row['govt_entity'],'Energy, Dept of')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '106C2C6E-F0E1-46E3-9409-294E0BD27878')
        self.failUnlessEqual(row['govt_entity'],
                             'HOUSE OF REPRESENTATIVES')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '106C2C6E-F0E1-46E3-9409-294E0BD27878')
        self.failUnlessEqual(row['govt_entity'],
                             'Federal Energy Regulatory Commission (FERC)')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '106C2C6E-F0E1-46E3-9409-294E0BD27878')
        self.failUnlessEqual(row['govt_entity'], 'SENATE')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'FFF29969-FDEC-4125-809E-0D8D2D8E73FC')
        self.failUnlessEqual(row['govt_entity'],
                             'Health & Human Services, Dept of  (HHS)')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'FFF29969-FDEC-4125-809E-0D8D2D8E73FC')
        self.failUnlessEqual(row['govt_entity'], 'SENATE')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'FFF29969-FDEC-4125-809E-0D8D2D8E73FC')
        self.failUnlessEqual(row['govt_entity'],
                             'HOUSE OF REPRESENTATIVES')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'FD29F4AF-763B-42A6-A27E-0AE115CD6D51')
        self.failUnlessEqual(row['govt_entity'], 'NONE')

        self.failUnlessEqual(len(rows), 0)
Пример #35
0
    def test_import_affiliated_orgs_org(self):
        """Importing affiliated orgs should fill the 'org' 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 org")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'PORTAL DEL FUTURO AUTHORITY')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'ITNL EMISSIONS TRADING ASSN')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'ISL')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'CHILDRENS HOSPITAL OAKLAND')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'INMARSAT LTD')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'UC GROUP LIMITED')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'N/A')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Time Warner Cable')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Palm, Inc.')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Warner Bros.')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'AOL')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Power Pyles Sutter & Verville')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Holland and Knight')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'HCR ManorCare')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Vitas')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Odyssey')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'AseraCare')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'UT-Battelle')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Brookhaven Science Association')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Ross Stores, Inc.')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Wal-Mart Stores, Inc.')

        row = rows.pop()
        self.failUnlessEqual(row['name'], "Land O'Lakes, Inc.")

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'SOUTHEASTERN FEDERAL POWER CUSTOME')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'Patton Boggs, LLP')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'CARITAS CHRISTI')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'BOSTON MEDICAL CENTER')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'PARTNERS HEALTHCARE SYSTEM')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'DANA FARBER CANCER INSTITUTE')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'ORANGE COUNTY TRANSPORTATION AUTHOR')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'JERRY REDDEN')

        row = rows.pop()
        self.failUnlessEqual(row['name'], 'EXXONMOBILE')

        self.failUnlessEqual(len(rows), 0)
Пример #36
0
    def test_import_filings_to_govt_entities(self):
        """Government entities are matched up with filings in the database."""
        filings = list(
            lobbyists.parse_filings(util.testpath('govt_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 filing_govt_entities")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '2627E811-33AB-43F4-B8E0-5B979A10FBF9')
        self.failUnlessEqual(row['govt_entity'], 'UNDETERMINED')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '106C2C6E-F0E1-46E3-9409-294E0BD27878')
        self.failUnlessEqual(row['govt_entity'],
                             'Federal Communications Commission (FCC)')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '106C2C6E-F0E1-46E3-9409-294E0BD27878')
        self.failUnlessEqual(row['govt_entity'],
                             'Environmental Protection Agency (EPA)')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '106C2C6E-F0E1-46E3-9409-294E0BD27878')
        self.failUnlessEqual(row['govt_entity'], 'Energy, Dept of')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '106C2C6E-F0E1-46E3-9409-294E0BD27878')
        self.failUnlessEqual(row['govt_entity'], 'HOUSE OF REPRESENTATIVES')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '106C2C6E-F0E1-46E3-9409-294E0BD27878')
        self.failUnlessEqual(row['govt_entity'],
                             'Federal Energy Regulatory Commission (FERC)')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '106C2C6E-F0E1-46E3-9409-294E0BD27878')
        self.failUnlessEqual(row['govt_entity'], 'SENATE')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'FFF29969-FDEC-4125-809E-0D8D2D8E73FC')
        self.failUnlessEqual(row['govt_entity'],
                             'Health & Human Services, Dept of  (HHS)')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'FFF29969-FDEC-4125-809E-0D8D2D8E73FC')
        self.failUnlessEqual(row['govt_entity'], 'SENATE')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'FFF29969-FDEC-4125-809E-0D8D2D8E73FC')
        self.failUnlessEqual(row['govt_entity'], 'HOUSE OF REPRESENTATIVES')

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'FD29F4AF-763B-42A6-A27E-0AE115CD6D51')
        self.failUnlessEqual(row['govt_entity'], 'NONE')

        self.failUnlessEqual(len(rows), 0)
Пример #37
0
    def test_import_affiliated_org_urls(self):
        """Importing affiliated orgs should fill the 'url' 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 url")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['url'],
                             'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['url'],
                             "are the members listed on coalition's website?")

        row = rows.pop()
        self.failUnlessEqual(row['url'],
                             'www.hklaw.com    www.ppsv.com')

        row = rows.pop()
        self.failUnlessEqual(row['url'],
                             'www.vitas.com, www.odyssey-healthcare.com, www.hcr-manorcare.com/home, www.aseracare.com')

        row = rows.pop()
        self.failUnlessEqual(row['url'],
                             'www.bnl.gov (Brookhaven Science Association);   www.ut-battelle.org (UT-Battelle)')

        row = rows.pop()
        self.failUnlessEqual(row['url'],
                             'www.wal-mart.com; www.rossstores.com')

        row = rows.pop()
        self.failUnlessEqual(row['url'],
                             'www.landolakesinc.com              4001 Lexington Ave. N, Arden Hills Minnesota 55112-6943')

        row = rows.pop()
        self.failUnlessEqual(row['url'], 'None')

        row = rows.pop()
        self.failUnlessEqual(row['url'],
                             'Patton Boggs, LLP, 2550 M. Street N.W., Washington, D.C. 20037 - [email protected]')

        row = rows.pop()
        self.failUnlessEqual(row['url'], 'N/A')

        row = rows.pop()
        self.failUnlessEqual(row['url'],  '*****@*****.**')

        row = rows.pop()
        self.failUnlessEqual(row['url'],
                             'http://skipjack.net/le_shore/worcestr/welcome.html')

        row = rows.pop()
        self.failUnlessEqual(row['url'], 'www.exxonmobile.com')

        self.failUnlessEqual(len(rows), 0)
Пример #38
0
    def test_import_issues_issue_code(self):
        """Importing issues should fill issue_code table."""
        filings = list(lobbyists.parse_filings(util.testpath('issues.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 issue_code")
        rows = list(cur)

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'ENERGY/NUCLEAR')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'TRANSPORTATION')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'IMMIGRATION')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'AGRICULTURE')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'TRADE (DOMESTIC/FOREIGN)')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'EDUCATION')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'ROADS/HIGHWAY')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'HOMELAND SECURITY')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'DEFENSE')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'BANKING')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'REAL ESTATE/LAND USE/CONSERVATION')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'FINANCIAL INSTITUTIONS/INVESTMENTS/SECURITIES')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'FOREIGN RELATIONS')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'LAW ENFORCEMENT/CRIME/CRIMINAL JUSTICE')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'FAMILY ISSUES/ABORTION/ADOPTION')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'HEALTH ISSUES')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'MEDICARE/MEDICAID')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'WELFARE')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'BUDGET/APPROPRIATIONS')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'TAXATION/INTERNAL REVENUE CODE')

        row = rows.pop()
        self.failUnlessEqual(row['code'],
                             'INSURANCE')

        self.failUnlessEqual(len(rows), 0)
Пример #39
0
    def test_import_issues(self):
        """Import issues"""
        filings = list(lobbyists.parse_filings(util.testpath('issues.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 issue")
        rows = list(cur)

        row = rows.pop()
        self.failUnlessEqual(row['id'], 23)
        self.failUnlessEqual(row['code'],
                             'ENERGY/NUCLEAR')
        self.failUnlessEqual(row['specific_issue'],
                             '\r\nComprehensive Energy Bill')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 22)
        self.failUnlessEqual(row['code'],
                             'TRANSPORTATION')
        self.failUnlessEqual(row['specific_issue'],
                             '\r\nH.R. 1495 Water Resources Development Act (WRDA) - the WRDA provisions to modernize the locks on the Upper Mississippi and Illinois Rivers are essential if U.S. agriculture is going to remain competitive in the global marketplace.\r\nH.R. 1495 the Water Resources Development Act of 2007 (WRDA) - conference report - Title VIII of the legislation includes authorization for the Corps of Engineers to construct new 1,200 foot locks on the Upper Mississippi and Illinois Rivers\n')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 21)
        self.failUnlessEqual(row['code'],
                             'IMMIGRATION')
        self.failUnlessEqual(row['specific_issue'],
                             '\r\nImmigration - Thanking Senator Lincoln and her staff for the hard work and long hours and dedication they presented in an effort to develop a comprehensive immigration reform.\n')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 20)
        self.failUnlessEqual(row['code'],
                             'AGRICULTURE')
        self.failUnlessEqual(row['specific_issue'],
                             '\r\nFY08 Agriculture Appropriations Bill - (Sec. 738) amendment to prohibit USDA from spending money for health inspection of horses.\n\nH.R. 3161, the FY08 Ag spending bill - amendments: King/Kingston amendment to strike Sec. 738. It would limit USDA authority for equine health inspection, effectively restricting the movement of all horses; Ackerman amendment prohibits funding for Food Safety and Inspection Service (FSIS) inspections in facilities that process nonambulatory or downer livestock;  Whitfield-Spratt-Rahall-Chandler amendment to restrict USDA inspection of horses intended for processing for human consumption.\n\nPayment Limits.\r\nFarm Bill: tax title, reductions in direct payments, counter-cyclical revenue option, senate ag committee markup on farm bill, amendments seeking further reform to payment limits and adjusted gross income restrictions.\n')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 19)
        self.failUnlessEqual(row['code'],
                             'TRADE (DOMESTIC/FOREIGN)')
        self.failUnlessEqual(row['specific_issue'],
                             '\r\nU.S. -Peru Trade Promotion Agreement (TPA) - the goal is to increase U.S. agriculture exports and increase market share.')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 18)
        self.failUnlessEqual(row['code'],
                             'EDUCATION')
        self.failUnlessEqual(row['specific_issue'],
                             '\r\nFY08 Labor, HHS and Education spending.  Perkins Amendment (federal funding for FFA and career and technical education).')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 17)
        self.failUnlessEqual(row['code'],
                             'ROADS/HIGHWAY')
        self.failUnlessEqual(row['specific_issue'],
                             '\r\nH.R. 3098 to restore farm truck exemptions from federal motor carrier vehicle regulations.')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 16)
        self.failUnlessEqual(row['code'],
                             'DEFENSE')
        self.failUnlessEqual(row['specific_issue'],
                             'H.R.3222 & Senate FY08 Defense Appropriations-Navy, Army & SOCOM R&D\nH.R.1585 & S.1547 FY08 Defense Authorizations-Navy, Army & SOCOM R&D\n')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 15)
        self.failUnlessEqual(row['code'],
                             'HOMELAND SECURITY')
        self.failUnlessEqual(row['specific_issue'],
                             'H.R.3222 & Senate FY08 Defense Appropriations-Navy, Army & SOCOM R&D\nH.R.1585 & S.1547 FY08 Defense Authorizations-Navy, Army & SOCOM R&D\nH.R.2638 & S.1644 FY08 DHS AppropriationsBill-CRP')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 14)
        self.failUnlessEqual(row['code'],
                             'BUDGET/APPROPRIATIONS')
        self.failUnlessEqual(row['specific_issue'],
                             'H.R.3222 & Senate FY08 Defense Appropriations-Navy, Army & SOCOM R&D\nH.R.1585 & S.1547 FY08 Defense Authorizations-Navy, Army & SOCOM R&D\nH.R.2638 & S.1644 FY08 DHS AppropriationsBill-CRP')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 13)
        self.failUnlessEqual(row['code'],
                             'DEFENSE')
        self.failUnlessEqual(row['specific_issue'],
                             'DEFENSE AUTHORIZATION, DEFENSE APPROPRIATIONS, VETERANS, DEFENSE HEALTH CARE, ARMED FORCES RETIREMENT, ARMED FORCES PERSONNEL BENEFITS, EMERGING DEFENSE RELATED ISSUES')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 12)
        self.failUnlessEqual(row['code'],
                             'BANKING')
        self.failUnlessEqual(row['specific_issue'],
                             'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 11)
        self.failUnlessEqual(row['code'],
                             'REAL ESTATE/LAND USE/CONSERVATION')
        self.failUnlessEqual(row['specific_issue'],
                             'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 10)
        self.failUnlessEqual(row['code'],
                             'FINANCIAL INSTITUTIONS/INVESTMENTS/SECURITIES')
        self.failUnlessEqual(row['specific_issue'],
                             'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 9)
        self.failUnlessEqual(row['code'],
                             'FOREIGN RELATIONS')
        self.failUnlessEqual(row['specific_issue'],
                             'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 8)
        self.failUnlessEqual(row['code'],
                             'LAW ENFORCEMENT/CRIME/CRIMINAL JUSTICE')
        self.failUnlessEqual(row['specific_issue'],
                             'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 7)
        self.failUnlessEqual(row['code'],
                             'FAMILY ISSUES/ABORTION/ADOPTION')
        self.failUnlessEqual(row['specific_issue'],
                             'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 6)
        self.failUnlessEqual(row['code'],
                             'HEALTH ISSUES')
        self.failUnlessEqual(row['specific_issue'],
                             'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 5)
        self.failUnlessEqual(row['code'],
                             'MEDICARE/MEDICAID')
        self.failUnlessEqual(row['specific_issue'],
                             'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 4)
        self.failUnlessEqual(row['code'],
                             'WELFARE')
        self.failUnlessEqual(row['specific_issue'],
                             'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 3)
        self.failUnlessEqual(row['code'],
                             'BUDGET/APPROPRIATIONS')
        self.failUnlessEqual(row['specific_issue'],
                             'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 2)
        self.failUnlessEqual(row['code'],
                             'TAXATION/INTERNAL REVENUE CODE')
        self.failUnlessEqual(row['specific_issue'],
                             'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 1)
        self.failUnlessEqual(row['code'],
                             'INSURANCE')
        self.failUnlessEqual(row['specific_issue'],
                             'unspecified')

        self.failUnlessEqual(len(rows), 0)
Пример #40
0
    def test_import_filings_to_issues(self):
        """Issues are matched up with filings in the database."""
        filings = list(lobbyists.parse_filings(util.testpath('issues.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 filing_issues")
        rows = list(cur)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 23)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 22)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 21)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 20)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 19)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 18)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 17)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], '05804BE5-57C9-41BF-97B2-0120826D4393')
        self.failUnlessEqual(row['issue'], 16)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], '05804BE5-57C9-41BF-97B2-0120826D4393')
        self.failUnlessEqual(row['issue'], 15)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], '05804BE5-57C9-41BF-97B2-0120826D4393')
        self.failUnlessEqual(row['issue'], 14)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'F56492FC-4FBD-4824-83E1-0004B30F0519')
        self.failUnlessEqual(row['issue'], 13)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'A55002C7-78C4-41BA-A6CA-01FCF7650116')
        self.failUnlessEqual(row['issue'], 12)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'A55002C7-78C4-41BA-A6CA-01FCF7650116')
        self.failUnlessEqual(row['issue'], 11)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'A55002C7-78C4-41BA-A6CA-01FCF7650116')
        self.failUnlessEqual(row['issue'], 10)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'A55002C7-78C4-41BA-A6CA-01FCF7650116')
        self.failUnlessEqual(row['issue'], 9)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'A55002C7-78C4-41BA-A6CA-01FCF7650116')
        self.failUnlessEqual(row['issue'], 8)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'A55002C7-78C4-41BA-A6CA-01FCF7650116')
        self.failUnlessEqual(row['issue'], 7)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'D1C9DB2A-AE4F-4FED-9BCB-024C8373813E')
        self.failUnlessEqual(row['issue'], 6)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'D1C9DB2A-AE4F-4FED-9BCB-024C8373813E')
        self.failUnlessEqual(row['issue'], 5)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'D1C9DB2A-AE4F-4FED-9BCB-024C8373813E')
        self.failUnlessEqual(row['issue'], 4)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'D1C9DB2A-AE4F-4FED-9BCB-024C8373813E')
        self.failUnlessEqual(row['issue'], 3)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'D1C9DB2A-AE4F-4FED-9BCB-024C8373813E')
        self.failUnlessEqual(row['issue'], 2)

        row = rows.pop()
        self.failUnlessEqual(row['filing'], 'D1C9DB2A-AE4F-4FED-9BCB-024C8373813E')
        self.failUnlessEqual(row['issue'], 1)

        self.failUnlessEqual(len(rows), 0)
Пример #41
0
    def test_import_filings_to_issues(self):
        """Issues are matched up with filings in the database."""
        filings = list(lobbyists.parse_filings(util.testpath('issues.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 filing_issues")
        rows = list(cur)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 23)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 22)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 21)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 20)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 19)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 18)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '79E53F91-8C5F-44AD-909D-032AA25D5B00')
        self.failUnlessEqual(row['issue'], 17)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '05804BE5-57C9-41BF-97B2-0120826D4393')
        self.failUnlessEqual(row['issue'], 16)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '05804BE5-57C9-41BF-97B2-0120826D4393')
        self.failUnlessEqual(row['issue'], 15)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '05804BE5-57C9-41BF-97B2-0120826D4393')
        self.failUnlessEqual(row['issue'], 14)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'F56492FC-4FBD-4824-83E1-0004B30F0519')
        self.failUnlessEqual(row['issue'], 13)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A55002C7-78C4-41BA-A6CA-01FCF7650116')
        self.failUnlessEqual(row['issue'], 12)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A55002C7-78C4-41BA-A6CA-01FCF7650116')
        self.failUnlessEqual(row['issue'], 11)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A55002C7-78C4-41BA-A6CA-01FCF7650116')
        self.failUnlessEqual(row['issue'], 10)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A55002C7-78C4-41BA-A6CA-01FCF7650116')
        self.failUnlessEqual(row['issue'], 9)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A55002C7-78C4-41BA-A6CA-01FCF7650116')
        self.failUnlessEqual(row['issue'], 8)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A55002C7-78C4-41BA-A6CA-01FCF7650116')
        self.failUnlessEqual(row['issue'], 7)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'D1C9DB2A-AE4F-4FED-9BCB-024C8373813E')
        self.failUnlessEqual(row['issue'], 6)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'D1C9DB2A-AE4F-4FED-9BCB-024C8373813E')
        self.failUnlessEqual(row['issue'], 5)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'D1C9DB2A-AE4F-4FED-9BCB-024C8373813E')
        self.failUnlessEqual(row['issue'], 4)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'D1C9DB2A-AE4F-4FED-9BCB-024C8373813E')
        self.failUnlessEqual(row['issue'], 3)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'D1C9DB2A-AE4F-4FED-9BCB-024C8373813E')
        self.failUnlessEqual(row['issue'], 2)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'D1C9DB2A-AE4F-4FED-9BCB-024C8373813E')
        self.failUnlessEqual(row['issue'], 1)

        self.failUnlessEqual(len(rows), 0)
Пример #42
0
    def test_import_filings_to_affiliated_orgs(self):
        """Affiliated orgs are matched up with filings in the database."""
        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 filing_affiliated_orgs")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'F0054303-E42F-48CE-8D71-CE7B2FBE8707')
        self.failUnlessEqual(row['url'],
                             'unspecified')
        self.failUnlessEqual(row['org'], 31)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A4F6A122-5550-46AF-9C5C-2838FF6538FE')
        self.failUnlessEqual(row['url'],
                             'unspecified')
        self.failUnlessEqual(row['org'], 30)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A0AA1F41-447E-4A0B-B09A-B0C24645F805')
        self.failUnlessEqual(row['url'],
                             'unspecified')
        self.failUnlessEqual(row['org'], 29)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A0AA1F41-447E-4A0B-B09A-B0C24645F805')
        self.failUnlessEqual(row['url'],
                             'unspecified')
        self.failUnlessEqual(row['org'], 28)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'E63105D4-9840-492D-A81E-F6816CBAFACE')
        self.failUnlessEqual(row['url'],
                             'unspecified')
        self.failUnlessEqual(row['org'], 27)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '9B506978-9D51-431A-A698-11F682485512')
        self.failUnlessEqual(row['url'],
                             'unspecified')
        self.failUnlessEqual(row['org'], 26)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'E8A4D9C9-2D0B-4F0A-966D-A076858D2751')
        self.failUnlessEqual(row['url'],
                             'unspecified')
        self.failUnlessEqual(row['org'], 25)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '493C9C11-17ED-4875-88D2-FAC96FF06849')
        self.failUnlessEqual(row['url'],
                             "are the members listed on coalition's website?")
        self.failUnlessEqual(row['org'], 24)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '493C9C11-17ED-4875-88D2-FAC96FF06849')
        self.failUnlessEqual(row['url'],
                             "are the members listed on coalition's website?")
        self.failUnlessEqual(row['org'], 23)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '493C9C11-17ED-4875-88D2-FAC96FF06849')
        self.failUnlessEqual(row['url'],
                             "are the members listed on coalition's website?")
        self.failUnlessEqual(row['org'], 22)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '493C9C11-17ED-4875-88D2-FAC96FF06849')
        self.failUnlessEqual(row['url'],
                             "are the members listed on coalition's website?")
        self.failUnlessEqual(row['org'], 21)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '9B5A4E46-8AAA-4497-B11A-B83B6D18836C')
        self.failUnlessEqual(row['url'],
                             'www.hklaw.com    www.ppsv.com')
        self.failUnlessEqual(row['org'], 20)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '9B5A4E46-8AAA-4497-B11A-B83B6D18836C')
        self.failUnlessEqual(row['url'],
                             'www.hklaw.com    www.ppsv.com')
        self.failUnlessEqual(row['org'], 19)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '5F456254-75FE-4ED2-8F74-92C169B6800A')
        self.failUnlessEqual(row['url'],
                             'www.vitas.com, www.odyssey-healthcare.com, www.hcr-manorcare.com/home, www.aseracare.com')
        self.failUnlessEqual(row['org'], 18)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '5F456254-75FE-4ED2-8F74-92C169B6800A')
        self.failUnlessEqual(row['url'],
                             'www.vitas.com, www.odyssey-healthcare.com, www.hcr-manorcare.com/home, www.aseracare.com')
        self.failUnlessEqual(row['org'], 17)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '5F456254-75FE-4ED2-8F74-92C169B6800A')
        self.failUnlessEqual(row['url'],
                             'www.vitas.com, www.odyssey-healthcare.com, www.hcr-manorcare.com/home, www.aseracare.com')
        self.failUnlessEqual(row['org'], 16)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '5F456254-75FE-4ED2-8F74-92C169B6800A')
        self.failUnlessEqual(row['url'],
                             'www.vitas.com, www.odyssey-healthcare.com, www.hcr-manorcare.com/home, www.aseracare.com')
        self.failUnlessEqual(row['org'], 15)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C6EABAE0-1E89-491F-97B3-5282386EC69C')
        self.failUnlessEqual(row['url'],
                             'www.bnl.gov (Brookhaven Science Association);   www.ut-battelle.org (UT-Battelle)')
        self.failUnlessEqual(row['org'], 14)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C6EABAE0-1E89-491F-97B3-5282386EC69C')
        self.failUnlessEqual(row['url'],
                             'www.bnl.gov (Brookhaven Science Association);   www.ut-battelle.org (UT-Battelle)')
        self.failUnlessEqual(row['org'], 13)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '8A3DB5DF-04A3-4002-9353-2C12104A0B49')
        self.failUnlessEqual(row['url'],
                             'www.wal-mart.com; www.rossstores.com')
        self.failUnlessEqual(row['org'], 12)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '8A3DB5DF-04A3-4002-9353-2C12104A0B49')
        self.failUnlessEqual(row['url'],
                             'www.wal-mart.com; www.rossstores.com')
        self.failUnlessEqual(row['org'], 11)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '6D4AFEE6-E886-4993-B153-14A887FD325A')
        self.failUnlessEqual(row['url'],
                             'www.landolakesinc.com              4001 Lexington Ave. N, Arden Hills Minnesota 55112-6943')
        self.failUnlessEqual(row['org'], 10)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'E34132EF-DA6D-40BF-BDEA-D13DBDF09BEA')
        self.failUnlessEqual(row['url'], 'None')
        self.failUnlessEqual(row['org'], 9)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '0C4051F5-2E0A-4ABC-A140-7FAFF7669D00')
        self.failUnlessEqual(row['url'],
                             'Patton Boggs, LLP, 2550 M. Street N.W., Washington, D.C. 20037 - [email protected]')
        self.failUnlessEqual(row['org'], 8)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C8293344-9A8D-4D6F-AAA5-25925E60BED9')
        self.failUnlessEqual(row['url'], 'N/A')
        self.failUnlessEqual(row['org'], 7)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C8293344-9A8D-4D6F-AAA5-25925E60BED9')
        self.failUnlessEqual(row['url'], 'N/A')
        self.failUnlessEqual(row['org'], 6)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C8293344-9A8D-4D6F-AAA5-25925E60BED9')
        self.failUnlessEqual(row['url'], 'N/A')
        self.failUnlessEqual(row['org'], 5)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C8293344-9A8D-4D6F-AAA5-25925E60BED9')
        self.failUnlessEqual(row['url'], 'N/A')
        self.failUnlessEqual(row['org'], 4)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C72D65BA-24D0-4AB7-97E4-7D68FD2BCB7D')
        self.failUnlessEqual(row['url'],  '*****@*****.**')
        self.failUnlessEqual(row['org'], 3)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '09C471E9-2B98-433A-8E4D-0C3928459C20')
        self.failUnlessEqual(row['url'],
                             'http://skipjack.net/le_shore/worcestr/welcome.html')
        self.failUnlessEqual(row['org'], 2)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '16E1EA9C-F6B3-4319-957E-14F4D65BD9F4')
        self.failUnlessEqual(row['url'], 'www.exxonmobile.com')
        self.failUnlessEqual(row['org'], 1)

        self.failUnlessEqual(len(rows), 0)
Пример #43
0
    def test_import_filings_to_affiliated_orgs(self):
        """Affiliated orgs are matched up with filings in the database."""
        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 filing_affiliated_orgs")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'F0054303-E42F-48CE-8D71-CE7B2FBE8707')
        self.failUnlessEqual(row['url'], 'unspecified')
        self.failUnlessEqual(row['org'], 31)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A4F6A122-5550-46AF-9C5C-2838FF6538FE')
        self.failUnlessEqual(row['url'], 'unspecified')
        self.failUnlessEqual(row['org'], 30)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A0AA1F41-447E-4A0B-B09A-B0C24645F805')
        self.failUnlessEqual(row['url'], 'unspecified')
        self.failUnlessEqual(row['org'], 29)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A0AA1F41-447E-4A0B-B09A-B0C24645F805')
        self.failUnlessEqual(row['url'], 'unspecified')
        self.failUnlessEqual(row['org'], 28)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'E63105D4-9840-492D-A81E-F6816CBAFACE')
        self.failUnlessEqual(row['url'], 'unspecified')
        self.failUnlessEqual(row['org'], 27)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '9B506978-9D51-431A-A698-11F682485512')
        self.failUnlessEqual(row['url'], 'unspecified')
        self.failUnlessEqual(row['org'], 26)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'E8A4D9C9-2D0B-4F0A-966D-A076858D2751')
        self.failUnlessEqual(row['url'], 'unspecified')
        self.failUnlessEqual(row['org'], 25)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '493C9C11-17ED-4875-88D2-FAC96FF06849')
        self.failUnlessEqual(row['url'],
                             "are the members listed on coalition's website?")
        self.failUnlessEqual(row['org'], 24)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '493C9C11-17ED-4875-88D2-FAC96FF06849')
        self.failUnlessEqual(row['url'],
                             "are the members listed on coalition's website?")
        self.failUnlessEqual(row['org'], 23)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '493C9C11-17ED-4875-88D2-FAC96FF06849')
        self.failUnlessEqual(row['url'],
                             "are the members listed on coalition's website?")
        self.failUnlessEqual(row['org'], 22)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '493C9C11-17ED-4875-88D2-FAC96FF06849')
        self.failUnlessEqual(row['url'],
                             "are the members listed on coalition's website?")
        self.failUnlessEqual(row['org'], 21)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '9B5A4E46-8AAA-4497-B11A-B83B6D18836C')
        self.failUnlessEqual(row['url'], 'www.hklaw.com    www.ppsv.com')
        self.failUnlessEqual(row['org'], 20)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '9B5A4E46-8AAA-4497-B11A-B83B6D18836C')
        self.failUnlessEqual(row['url'], 'www.hklaw.com    www.ppsv.com')
        self.failUnlessEqual(row['org'], 19)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '5F456254-75FE-4ED2-8F74-92C169B6800A')
        self.failUnlessEqual(
            row['url'],
            'www.vitas.com, www.odyssey-healthcare.com, www.hcr-manorcare.com/home, www.aseracare.com'
        )
        self.failUnlessEqual(row['org'], 18)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '5F456254-75FE-4ED2-8F74-92C169B6800A')
        self.failUnlessEqual(
            row['url'],
            'www.vitas.com, www.odyssey-healthcare.com, www.hcr-manorcare.com/home, www.aseracare.com'
        )
        self.failUnlessEqual(row['org'], 17)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '5F456254-75FE-4ED2-8F74-92C169B6800A')
        self.failUnlessEqual(
            row['url'],
            'www.vitas.com, www.odyssey-healthcare.com, www.hcr-manorcare.com/home, www.aseracare.com'
        )
        self.failUnlessEqual(row['org'], 16)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '5F456254-75FE-4ED2-8F74-92C169B6800A')
        self.failUnlessEqual(
            row['url'],
            'www.vitas.com, www.odyssey-healthcare.com, www.hcr-manorcare.com/home, www.aseracare.com'
        )
        self.failUnlessEqual(row['org'], 15)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C6EABAE0-1E89-491F-97B3-5282386EC69C')
        self.failUnlessEqual(
            row['url'],
            'www.bnl.gov (Brookhaven Science Association);   www.ut-battelle.org (UT-Battelle)'
        )
        self.failUnlessEqual(row['org'], 14)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C6EABAE0-1E89-491F-97B3-5282386EC69C')
        self.failUnlessEqual(
            row['url'],
            'www.bnl.gov (Brookhaven Science Association);   www.ut-battelle.org (UT-Battelle)'
        )
        self.failUnlessEqual(row['org'], 13)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '8A3DB5DF-04A3-4002-9353-2C12104A0B49')
        self.failUnlessEqual(row['url'],
                             'www.wal-mart.com; www.rossstores.com')
        self.failUnlessEqual(row['org'], 12)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '8A3DB5DF-04A3-4002-9353-2C12104A0B49')
        self.failUnlessEqual(row['url'],
                             'www.wal-mart.com; www.rossstores.com')
        self.failUnlessEqual(row['org'], 11)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '6D4AFEE6-E886-4993-B153-14A887FD325A')
        self.failUnlessEqual(
            row['url'],
            'www.landolakesinc.com              4001 Lexington Ave. N, Arden Hills Minnesota 55112-6943'
        )
        self.failUnlessEqual(row['org'], 10)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'E34132EF-DA6D-40BF-BDEA-D13DBDF09BEA')
        self.failUnlessEqual(row['url'], 'None')
        self.failUnlessEqual(row['org'], 9)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '0C4051F5-2E0A-4ABC-A140-7FAFF7669D00')
        self.failUnlessEqual(
            row['url'],
            'Patton Boggs, LLP, 2550 M. Street N.W., Washington, D.C. 20037 - [email protected]'
        )
        self.failUnlessEqual(row['org'], 8)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C8293344-9A8D-4D6F-AAA5-25925E60BED9')
        self.failUnlessEqual(row['url'], 'N/A')
        self.failUnlessEqual(row['org'], 7)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C8293344-9A8D-4D6F-AAA5-25925E60BED9')
        self.failUnlessEqual(row['url'], 'N/A')
        self.failUnlessEqual(row['org'], 6)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C8293344-9A8D-4D6F-AAA5-25925E60BED9')
        self.failUnlessEqual(row['url'], 'N/A')
        self.failUnlessEqual(row['org'], 5)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C8293344-9A8D-4D6F-AAA5-25925E60BED9')
        self.failUnlessEqual(row['url'], 'N/A')
        self.failUnlessEqual(row['org'], 4)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'C72D65BA-24D0-4AB7-97E4-7D68FD2BCB7D')
        self.failUnlessEqual(row['url'], '*****@*****.**')
        self.failUnlessEqual(row['org'], 3)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '09C471E9-2B98-433A-8E4D-0C3928459C20')
        self.failUnlessEqual(
            row['url'], 'http://skipjack.net/le_shore/worcestr/welcome.html')
        self.failUnlessEqual(row['org'], 2)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '16E1EA9C-F6B3-4319-957E-14F4D65BD9F4')
        self.failUnlessEqual(row['url'], 'www.exxonmobile.com')
        self.failUnlessEqual(row['org'], 1)

        self.failUnlessEqual(len(rows), 0)
    def test_import_foreign_entities(self):
        """Import foreign entities"""
        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 foreign_entity")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['id'], 16)
        self.failUnlessEqual(row['name'], 'THE NEWS CORPORATION LTD.')
        self.failUnlessEqual(row['country'], 'UNDETERMINED')
        self.failUnlessEqual(row['ppb_country'], 'AUSTRALIA')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 15)
        self.failUnlessEqual(row['name'], 'EMBASSY OF VENEZUELA')
        self.failUnlessEqual(row['country'], 'UNDETERMINED')
        self.failUnlessEqual(row['ppb_country'], 'USA')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 14)
        self.failUnlessEqual(row['name'], 'Japan Tobacco Inc.')
        self.failUnlessEqual(row['country'], 'JAPAN')
        self.failUnlessEqual(row['ppb_country'], 'JAPAN')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 13)
        self.failUnlessEqual(row['name'], 'N/A')
        self.failUnlessEqual(row['country'], 'USA')
        self.failUnlessEqual(row['ppb_country'], 'UNDETERMINED')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 12)
        self.failUnlessEqual(row['name'], 'N/A')
        self.failUnlessEqual(row['country'], 'UNDETERMINED')
        self.failUnlessEqual(row['ppb_country'], 'UNDETERMINED')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 11)
        self.failUnlessEqual(row['name'], 'WALLETTE, GERALD')
        self.failUnlessEqual(row['country'], 'USA')
        self.failUnlessEqual(row['ppb_country'], 'USA')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 10)
        self.failUnlessEqual(row['name'],
                             'CITIZENS FOR DEMOCRACTIC RULE IN NIGERIA')
        self.failUnlessEqual(row['country'], 'USA')
        self.failUnlessEqual(row['ppb_country'], 'USA')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 9)
        self.failUnlessEqual(row['name'],
                             'CITIZENS FOR DEMOCRACTIC RULE IN NIGERIA')
        self.failUnlessEqual(row['country'], 'UNDETERMINED')
        self.failUnlessEqual(row['ppb_country'], 'UNDETERMINED')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 8)
        self.failUnlessEqual(row['name'], 'Beta Gamma Ltd.')
        self.failUnlessEqual(row['country'], 'SEYCHELLES')
        self.failUnlessEqual(row['ppb_country'], 'SEYCHELLES')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 7)
        self.failUnlessEqual(row['name'], "FBC Group Ltd.")
        self.failUnlessEqual(row['country'], 'UNITED KINGDOM')
        self.failUnlessEqual(row['ppb_country'], 'UNITED KINGDOM')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 6)
        self.failUnlessEqual(row['name'], 'AgustaWestland Holdings, Ltd.')
        self.failUnlessEqual(row['country'], '<SELECT ONE>')
        self.failUnlessEqual(row['ppb_country'], '<SELECT ONE>')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 5)
        self.failUnlessEqual(row['name'], 'HITACHI, LTD.')
        self.failUnlessEqual(row['country'], 'unspecified')
        self.failUnlessEqual(row['ppb_country'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 4)
        self.failUnlessEqual(row['name'], 'EVONIK INDUSTRIES GMBH')
        self.failUnlessEqual(row['country'], 'GERMANY')
        self.failUnlessEqual(row['ppb_country'], 'USA')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 3)
        self.failUnlessEqual(row['name'], 'MARUHA CORP')
        self.failUnlessEqual(row['country'], 'JAPAN')
        self.failUnlessEqual(row['ppb_country'], 'JAPAN')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 2)
        self.failUnlessEqual(row['name'], 'HOKO FISHING CO')
        self.failUnlessEqual(row['country'], 'JAPAN')
        self.failUnlessEqual(row['ppb_country'], 'JAPAN')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 1)
        self.failUnlessEqual(row['name'], 'NORTH JAPAN MARITIME CORP')
        self.failUnlessEqual(row['country'], 'JAPAN')
        self.failUnlessEqual(row['ppb_country'], 'JAPAN')

        self.failUnlessEqual(len(rows), 0)
    def test_import_lobbyists(self):
        """Lobbyist importing."""
        filings = list(lobbyists.parse_filings(util.testpath('lobbyists.xml')))
        con = sqlite3.connect(':memory:')
        con = lobbyists.create_db(con)
        cur = con.cursor()
        self.failUnless(lobbyists.import_filings(cur, filings))

        # Some of the other import tests just compare the parsed
        # filings to the contents of the database, but for various
        # reasons that's difficult for lobbyist records.  Instead,
        # this test has knowledge of the contents of the
        # 'lobbyists.xml' test file, and checks the database contents
        # explicitly, ala the parser tests in test_parser.py.
        con.row_factory = sqlite3.Row
        cur = con.cursor()
        cur.execute("SELECT * FROM lobbyist")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['id'], 16)
        self.failUnlessEqual(row['name'], 'KNUTSON, KENT')
        self.failUnlessEqual(row['indicator'], 'undetermined')
        self.failUnlessEqual(row['official_position'], 'N/A')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 15)
        self.failUnlessEqual(row['name'], 'KNUTSON, KENT')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'N/A')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 14)
        self.failUnlessEqual(row['name'], 'CHAMPLIN, STEVEN')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'],
                             'ExecFlrAsst, H. Maj. Whip; ExecDir, H.DemCauc.')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 13)
        self.failUnlessEqual(row['name'], 'GRIFFIN, BRIAN')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'],
                             'StaffAsst, DemPolicyComm; FlrAsst, MinoritySec')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 12)
        self.failUnlessEqual(row['name'], 'DUBERSTEIN, KENNETH')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'],
                             'Chief of Staff, President Reagan')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 11)
        self.failUnlessEqual(row['name'], 'UELAND, ERIC')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'],
                             'AsstEditor/Ed./Res.Dir, Sen.Rep.PolicyComm;')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 10)
        self.failUnlessEqual(row['name'], 'BEDWELL, EDWARD T')
        self.failUnlessEqual(row['indicator'], 'undetermined')
        self.failUnlessEqual(row['official_position'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 9)
        self.failUnlessEqual(row['name'], 'LEHMAN (MY 2006), PATRICK')
        self.failUnlessEqual(row['indicator'], 'undetermined')
        self.failUnlessEqual(row['official_position'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 8)
        self.failUnlessEqual(row['name'], 'NEAL, KATIE')
        self.failUnlessEqual(row['indicator'], 'covered')
        self.failUnlessEqual(row['official_position'], 'COMM DIR/REP DINGELL')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 7)
        self.failUnlessEqual(row['name'], 'NEAL, KATIE')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'N/A')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 6)
        self.failUnlessEqual(row['name'], 'NEAL, KATIE')
        self.failUnlessEqual(row['indicator'], 'undetermined')
        self.failUnlessEqual(row['official_position'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 5)
        self.failUnlessEqual(row['name'], 'unspecified')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 4)
        self.failUnlessEqual(row['name'], 'MCKENNEY, WILLIAM')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'],
                             'Staff Director, Ways & Means Over Sub')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 3)
        self.failUnlessEqual(row['name'], 'DENNIS, JAMES')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'],
                             'Tax Counsel, Sen Robb - Counsel, Sen Bingaman')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 2)
        self.failUnlessEqual(row['name'], 'GRAFMEYER, RICHARD')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'],
                             'Deputy Chief of Staff, JCT')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 1)
        self.failUnlessEqual(row['name'], 'HARRIS, ROBERT L.')
        self.failUnlessEqual(row['indicator'], 'undetermined')
        self.failUnlessEqual(row['official_position'], 'unspecified')

        self.failUnlessEqual(len(rows), 0)
    def test_import_filing_to_foreign_entities(self):
        """Foreign entities are matched up with filings in the database."""
        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 filing_foreign_entities")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'E4382341-0E5D-4A31-8A7D-3CCB71E8EF6E')
        self.failUnlessEqual(row['contribution'], 0)
        self.failUnlessEqual(row['ownership_percentage'], 34)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 16)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'EEDBB5F5-8BB4-4E0D-9F10-CD8FDD2A0D70')
        self.failUnlessEqual(row['contribution'], 100000)
        self.failUnlessEqual(row['ownership_percentage'], 0)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 15)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BBF87FC8-73FC-4050-B6F8-850C79EC72E2')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], 100)
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['foreign_entity'], 14)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'CE714D21-6713-4764-87F2-5F6294F0FBB3')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 13)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'CE714D21-6713-4764-87F2-5F6294F0FBB3')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'terminated')
        self.failUnlessEqual(row['foreign_entity'], 12)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BECA0C94-4308-47E5-BF23-887D3954E254')
        self.failUnlessEqual(row['contribution'], 0)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 11)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BECA0C94-4308-47E5-BF23-887D3954E254')
        self.failUnlessEqual(row['contribution'], 0)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 10)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BECA0C94-4308-47E5-BF23-887D3954E254')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 9)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '4CAC3894-FA4C-4CEC-99C7-1141544CA49B')
        self.failUnlessEqual(row['contribution'], 300000)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['foreign_entity'], 8)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '4CAC3894-FA4C-4CEC-99C7-1141544CA49B')
        self.failUnlessEqual(row['contribution'], 300000)
        self.failUnlessEqual(row['ownership_percentage'], 100)
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['foreign_entity'], 7)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '63AC4585-74BC-478D-A356-FCCFD98FDE64')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], 100)
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['foreign_entity'], 6)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '498EAE8A-DE7A-4FFF-A813-062D92FDA271')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], 100)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 5)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'ACD87507-EB78-4607-95E8-43871D9D1EF2')
        self.failUnlessEqual(row['contribution'], None)
        self.failUnlessEqual(row['ownership_percentage'], 100)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 4)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A9F81F8B-F0B0-440A-8564-051FF553CCA8')
        self.failUnlessEqual(row['contribution'], 0)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 3)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A9F81F8B-F0B0-440A-8564-051FF553CCA8')
        self.failUnlessEqual(row['contribution'], 16500)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 2)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'A9F81F8B-F0B0-440A-8564-051FF553CCA8')
        self.failUnlessEqual(row['contribution'], 16500)
        self.failUnlessEqual(row['ownership_percentage'], None)
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['foreign_entity'], 1)

        self.failUnlessEqual(len(rows), 0)
Пример #47
0
    def test_import_lobbyists(self):
        """Lobbyist importing."""
        filings = list(lobbyists.parse_filings(util.testpath('lobbyists.xml')))
        con = sqlite3.connect(':memory:')
        con = lobbyists.create_db(con)
        cur = con.cursor()
        self.failUnless(lobbyists.import_filings(cur, filings))

        # Some of the other import tests just compare the parsed
        # filings to the contents of the database, but for various
        # reasons that's difficult for lobbyist records.  Instead,
        # this test has knowledge of the contents of the
        # 'lobbyists.xml' test file, and checks the database contents
        # explicitly, ala the parser tests in test_parser.py.
        con.row_factory = sqlite3.Row
        cur = con.cursor()
        cur.execute("SELECT * FROM lobbyist")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['id'], 16)
        self.failUnlessEqual(row['name'], 'KNUTSON, KENT')
        self.failUnlessEqual(row['indicator'], 'undetermined')
        self.failUnlessEqual(row['official_position'], 'N/A')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 15)
        self.failUnlessEqual(row['name'], 'KNUTSON, KENT')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'N/A')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 14)
        self.failUnlessEqual(row['name'], 'CHAMPLIN, STEVEN')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'ExecFlrAsst, H. Maj. Whip; ExecDir, H.DemCauc.')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 13)
        self.failUnlessEqual(row['name'], 'GRIFFIN, BRIAN')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'StaffAsst, DemPolicyComm; FlrAsst, MinoritySec')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 12)
        self.failUnlessEqual(row['name'], 'DUBERSTEIN, KENNETH')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'Chief of Staff, President Reagan')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 11)
        self.failUnlessEqual(row['name'], 'UELAND, ERIC')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'AsstEditor/Ed./Res.Dir, Sen.Rep.PolicyComm;')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 10)
        self.failUnlessEqual(row['name'], 'BEDWELL, EDWARD T')
        self.failUnlessEqual(row['indicator'], 'undetermined')
        self.failUnlessEqual(row['official_position'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 9)
        self.failUnlessEqual(row['name'], 'LEHMAN (MY 2006), PATRICK')
        self.failUnlessEqual(row['indicator'], 'undetermined')
        self.failUnlessEqual(row['official_position'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 8)
        self.failUnlessEqual(row['name'], 'NEAL, KATIE')
        self.failUnlessEqual(row['indicator'], 'covered')
        self.failUnlessEqual(row['official_position'], 'COMM DIR/REP DINGELL')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 7)
        self.failUnlessEqual(row['name'], 'NEAL, KATIE')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'N/A')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 6)
        self.failUnlessEqual(row['name'], 'NEAL, KATIE')
        self.failUnlessEqual(row['indicator'], 'undetermined')
        self.failUnlessEqual(row['official_position'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 5)
        self.failUnlessEqual(row['name'], 'unspecified')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'unspecified')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 4)
        self.failUnlessEqual(row['name'], 'MCKENNEY, WILLIAM')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'Staff Director, Ways & Means Over Sub')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 3)
        self.failUnlessEqual(row['name'], 'DENNIS, JAMES')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'Tax Counsel, Sen Robb - Counsel, Sen Bingaman')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 2)
        self.failUnlessEqual(row['name'], 'GRAFMEYER, RICHARD')
        self.failUnlessEqual(row['indicator'], 'not covered')
        self.failUnlessEqual(row['official_position'], 'Deputy Chief of Staff, JCT')

        row = rows.pop()
        self.failUnlessEqual(row['id'], 1)
        self.failUnlessEqual(row['name'], 'HARRIS, ROBERT L.')
        self.failUnlessEqual(row['indicator'], 'undetermined')
        self.failUnlessEqual(row['official_position'], 'unspecified')

        self.failUnlessEqual(len(rows), 0)
    def test_import_filings_to_lobbyists(self):
        """Lobbyists are matched up with filings in the database."""
        filings = list(lobbyists.parse_filings(util.testpath('lobbyists.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 filing_lobbyists")
        rows = [row for row in cur]

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '771F3B6A-315D-4190-88F3-2CE0F138B2B8')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 16)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '771F3B6A-315D-4190-88F3-2CE0F138B2B8')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 15)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BD894C51-AA23-46AE-9802-006B8C91702B')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 14)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BD894C51-AA23-46AE-9802-006B8C91702B')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 13)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BD894C51-AA23-46AE-9802-006B8C91702B')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 12)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             'BD894C51-AA23-46AE-9802-006B8C91702B')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 11)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '2164D6BB-EBBA-40D2-9C18-16A2D670030A')
        self.failUnlessEqual(row['status'], 'terminated')
        self.failUnlessEqual(row['lobbyist'], 10)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '87A30FA6-7C35-4294-BA43-4CE7B5B808B3')
        self.failUnlessEqual(row['status'], 'terminated')
        self.failUnlessEqual(row['lobbyist'], 9)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '0FC23296-F948-43FD-98D4-0912F6579E6A')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 8)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '0FC23296-F948-43FD-98D4-0912F6579E6A')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 7)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '0FC23296-F948-43FD-98D4-0912F6579E6A')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 6)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '02DDA99B-725A-4DBA-8397-34892A6918D7')
        self.failUnlessEqual(row['status'], 'terminated')
        self.failUnlessEqual(row['lobbyist'], 5)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '02DDA99B-725A-4DBA-8397-34892A6918D7')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 4)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '02DDA99B-725A-4DBA-8397-34892A6918D7')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 3)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '02DDA99B-725A-4DBA-8397-34892A6918D7')
        self.failUnlessEqual(row['status'], 'active')
        self.failUnlessEqual(row['lobbyist'], 2)

        row = rows.pop()
        self.failUnlessEqual(row['filing'],
                             '04926911-8A12-4A0E-9DA4-510869446EAC')
        self.failUnlessEqual(row['status'], 'undetermined')
        self.failUnlessEqual(row['lobbyist'], 1)