def test_setup_db(mock_connect): d = nycdb.Dataset('pluto_16v2', args=ARGS) assert d.db is None d.setup_db() d.setup_db() assert isinstance(d.db, nycdb.Database) assert mock_connect.call_count == 1
def test_hpd_violations(): conn = connection() drop_table(conn, 'hpd_violations') hpd_violations = nycdb.Dataset('hpd_violations', args=ARGS) hpd_violations.db_import() assert row_count(conn, 'hpd_violations') == 100 conn.close()
def test_pluto17v1(): conn = connection() drop_table(conn, 'pluto_17v1') pluto = nycdb.Dataset('pluto_17v1', args=ARGS) pluto.db_import() assert row_count(conn, 'pluto_17v1') == 500 conn.close()
def test_hpd_registrations(conn): drop_table(conn, 'hpd_registrations') drop_table(conn, 'hpd_contacts') ds = nycdb.Dataset('hpd_registrations', args=ARGS) ds.db_import() assert row_count(conn, 'hpd_registrations') == 100 assert row_count(conn, 'hpd_contacts') == 100
def test_acris(conn): drop_table(conn, 'real_property_legals') drop_table(conn, 'real_property_master') drop_table(conn, 'real_property_parties') drop_table(conn, 'real_property_references') drop_table(conn, 'real_property_remarks') drop_table(conn, 'personal_property_legals') drop_table(conn, 'personal_property_master') drop_table(conn, 'personal_property_parties') drop_table(conn, 'personal_property_references') drop_table(conn, 'personal_property_remarks') drop_table(conn, 'acris_country_codes') drop_table(conn, 'acris_document_control_codes') drop_table(conn, 'acris_property_type_codes') drop_table(conn, 'acris_ucc_collateral_codes') acris = nycdb.Dataset('acris', args=ARGS) acris.db_import() assert row_count(conn, 'real_property_legals') == 100 assert row_count(conn, 'real_property_master') == 100 assert row_count(conn, 'real_property_parties') == 100 assert row_count(conn, 'real_property_references') == 100 assert row_count(conn, 'real_property_remarks') == 10 assert row_count(conn, 'personal_property_legals') == 100 assert row_count(conn, 'personal_property_master') == 100 assert row_count(conn, 'personal_property_parties') == 100 assert row_count(conn, 'personal_property_references') == 10 assert row_count(conn, 'personal_property_remarks') == 10 assert row_count(conn, 'acris_country_codes') == 250 assert row_count(conn, 'acris_document_control_codes') == 123 assert row_count(conn, 'acris_property_type_codes') == 46 assert row_count(conn, 'acris_ucc_collateral_codes') == 8 assert has_one_row( conn, "select * from real_property_legals where bbl = '4131600009'")
def test_oca(conn): drop_table(conn, 'oca_index') drop_table(conn, 'oca_causes') drop_table(conn, 'oca_addresses') drop_table(conn, 'oca_parties') drop_table(conn, 'oca_events') drop_table(conn, 'oca_appearances') drop_table(conn, 'oca_appearance_outcomes') drop_table(conn, 'oca_motions') drop_table(conn, 'oca_decisions') drop_table(conn, 'oca_judgments') drop_table(conn, 'oca_warrants') oca = nycdb.Dataset('oca', args=ARGS) oca.db_import() assert row_count(conn, 'oca_index') == 50 assert row_count(conn, 'oca_causes') == 50 assert row_count(conn, 'oca_addresses') == 50 assert row_count(conn, 'oca_parties') == 122 assert row_count(conn, 'oca_events') == 89 assert row_count(conn, 'oca_appearances') == 123 assert row_count(conn, 'oca_appearance_outcomes') == 106 assert row_count(conn, 'oca_motions') == 39 assert row_count(conn, 'oca_decisions') == 24 assert row_count(conn, 'oca_judgments') == 23 assert row_count(conn, 'oca_warrants') == 23 case = '00000414FEEFDB09FADC092CBA4A47C2D997FDE65E31F18F3A40F0BF4060BDAD' assert has_one_row( conn, f"select * from oca_index where indexnumberid = '{case}'")
def test_dob_complaints(): conn = connection() drop_table(conn, 'dob_complaints') dob_complaints = nycdb.Dataset('dob_complaints', args=ARGS) dob_complaints.db_import() assert row_count(conn, 'dob_complaints') == 100 conn.close()
def test_dataset(): d = nycdb.Dataset('pluto_16v2', args=ARGS) assert d.name == 'pluto_16v2' assert d.dataset == nycdb.datasets()['pluto_16v2'] assert isinstance(d.files, list) assert len(d.files) == 1 assert isinstance(d.files[0], nycdb.File)
def test_rentstab(conn): drop_table(conn, 'rentstab') rentstab = nycdb.Dataset('rentstab', args=ARGS) rentstab.db_import() assert row_count(conn, 'rentstab') == 100 assert has_one_row( conn, "select 1 where to_regclass('public.rentstab_ucbbl_idx') is NOT NULL")
def test_dof_sales(conn): drop_table(conn, 'dof_sales') dof_sales = nycdb.Dataset('dof_sales', args=ARGS) dof_sales.db_import() assert row_count(conn, 'dof_sales') == 70 assert has_one_row( conn, "select 1 where to_regclass('public.dof_sales_bbl_idx') is NOT NULL")
def test_pad(conn): drop_table(conn, 'pad_adr') pad = nycdb.Dataset('pad', args=ARGS) pad.db_import() assert row_count(conn, 'pad_adr') == 100 with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as curs: curs.execute("select * from pad_adr WHERE bin = '1086410'") rec = curs.fetchone() assert rec is not None assert rec['bbl'] == '1000010010'
def test_oath_hearings(conn): drop_table(conn, 'oath_hearings') oath_hearings = nycdb.Dataset('oath_hearings', args=ARGS) oath_hearings.db_import() assert row_count(conn, 'oath_hearings') == 100 with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as curs: curs.execute("select * from oath_hearings WHERE bbl = '{}'".format('1020260001')) rec = curs.fetchone() assert rec is not None assert rec['totalviolationamount'] == Decimal('40000.00')
def test_hpd_vacateorders(conn): drop_table(conn, 'hpd_vacateorders') dataset = nycdb.Dataset('hpd_vacateorders', args=ARGS) dataset.db_import() assert row_count(conn, 'hpd_vacateorders') == 100 with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as curs: curs.execute("select * from hpd_vacateorders WHERE vacateordernumber = 100282") rec = curs.fetchone() assert rec is not None assert rec['bbl'] == '3013480010'
def test_j51_exemptions(conn): drop_table(conn, 'j51_exemptions') j51_exemptions = nycdb.Dataset('j51_exemptions', args=ARGS) j51_exemptions.db_import() assert row_count(conn, 'j51_exemptions') == 100 with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as curs: curs.execute("select * from j51_exemptions WHERE bbl = '1000151001'") rec = curs.fetchone() assert rec is not None assert rec['taxyear'] == 2001
def test_dob_violations(conn): drop_table(conn, 'dob_violations') dob_violations = nycdb.Dataset('dob_violations', args=ARGS) dob_violations.db_import() assert row_count(conn, 'dob_violations') == 100 # 3028850001 with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as curs: curs.execute("select * from dob_violations WHERE bbl = '{}'".format('3028850001')) rec = curs.fetchone() assert rec is not None assert rec['violationtypecode'] == 'LL6291'
def test_dobjobs_work_types(conn): drop_table(conn, 'dobjobs') dobjobs = nycdb.Dataset('dobjobs', args=ARGS) dobjobs.db_import() with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as curs: curs.execute("select * from dobjobs WHERE job = '{}'".format('310077591')) rec = curs.fetchone() assert rec['landmarked'] is False assert rec['loftboard'] is None assert rec['pcfiled'] is True assert rec['mechanical'] is True
def test_marshal_evictions_17(conn): drop_table(conn, 'marshal_evictions_17') evictions = nycdb.Dataset('marshal_evictions_17', args=ARGS) evictions.db_import() assert row_count(conn, 'marshal_evictions_17') == 10 test_id = '60479/177111610280' with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as curs: curs.execute( "select * from marshal_evictions_17 WHERE uniqueid = '{}'".format( test_id)) rec = curs.fetchone() assert rec is not None assert rec['lat'] == Decimal('40.71081')
def test_dobjobs(conn): drop_table(conn, 'dobjobs') dobjobs = nycdb.Dataset('dobjobs', args=ARGS) dobjobs.db_import() assert row_count(conn, 'dobjobs') == 100 columns = table_columns(conn, 'dobjobs') # test for columns add in add_columns.sql assert 'address' in columns assert 'ownername' in columns # full text columns shouldn't be inserted by default assert 'ownername_tsvector' not in columns dobjobs.index() columns = table_columns(conn, 'dobjobs') assert 'ownername_tsvector' in columns assert 'applicantname_tsvector' in columns
def test_oca(conn): drop_table(conn, 'oca_index') drop_table(conn, 'oca_causes') drop_table(conn, 'oca_addresses') drop_table(conn, 'oca_parties') drop_table(conn, 'oca_events') drop_table(conn, 'oca_appearances') drop_table(conn, 'oca_appearance_outcomes') drop_table(conn, 'oca_motions') drop_table(conn, 'oca_decisions') drop_table(conn, 'oca_judgments') drop_table(conn, 'oca_warrants') oca = nycdb.Dataset('oca', args=ARGS) oca.db_import() assert row_count(conn, 'oca_index') == 100 assert row_count(conn, 'oca_causes') == 100 assert row_count(conn, 'oca_addresses') == 100 assert row_count(conn, 'oca_parties') == 100 assert row_count(conn, 'oca_events') == 100 assert row_count(conn, 'oca_appearances') == 100 assert row_count(conn, 'oca_appearance_outcomes') == 100 assert row_count(conn, 'oca_motions') == 100 assert row_count(conn, 'oca_decisions') == 100 assert row_count(conn, 'oca_judgments') == 100 assert row_count(conn, 'oca_warrants') == 100 test_id = '000146FB4347DEDD75BD9817F6FA786E6B978ACA16FA54CAEDD5D48B16DD53E5' assert has_one_row( conn, f"select * from oca_index where indexnumberid = '{test_id}'") with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as curs: curs.execute( "select * from oca_index WHERE indexnumberid = '{}'".format( test_id)) rec = curs.fetchone() assert rec is not None assert rec['court'] == 'Kings County Civil Court' assert rec['fileddate'].strftime('%Y-%m-%d') == '2016-02-04' assert rec['specialtydesignationtypes'] == ['Specialty (HHP) Zipcodes'] assert rec['primaryclaimtotal'] == Decimal('2740.46') # make sure datatimes are working test_id = '00000131D2D43B62D4764607D1AB017FC536618A72F3795716341A8DD100CBEF' with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as curs: curs.execute( "select * from oca_appearances WHERE indexnumberid = '{}'".format( test_id)) rec = curs.fetchone() assert rec is not None assert rec['appearancedatetime'].strftime( '%Y-%m-%d %I:%M:%S') == '2016-05-11 09:30:00'
def test_dob_complaints(conn): drop_table(conn, 'dob_complaints') dob_complaints = nycdb.Dataset('dob_complaints', args=ARGS) dob_complaints.db_import() assert row_count(conn, 'dob_complaints') == 100
def test_rentstab_summary(conn): drop_table(conn, 'rentstab_summary') rentstab_summary = nycdb.Dataset('rentstab_summary', args=ARGS) rentstab_summary.db_import() assert row_count(conn, 'rentstab_summary') == 100
def load_dataset(self, name: str): '''Load the given NYCDB dataset into the database.''' nycdb.Dataset(name, args=self.args).db_import()
def test_rentstab_v2(conn): drop_table(conn, 'rentstab_v2') rentstab_v2 = nycdb.Dataset('rentstab_v2', args=ARGS) rentstab_v2.db_import() assert row_count(conn, 'rentstab_v2') == 100
def test_ecb_violations(conn): drop_table(conn, 'ecb_violations') ecb_violations = nycdb.Dataset('ecb_violations', args=ARGS) ecb_violations.db_import() assert row_count(conn, 'ecb_violations') == 5
def test_hpd_complaints(conn): drop_table(conn, 'hpd_complaint_problems') drop_table(conn, 'hpd_complaints') hpd_complaints = nycdb.Dataset('hpd_complaints', args=ARGS) hpd_complaints.db_import() assert row_count(conn, 'hpd_complaints') == 100
def test_pluto18v2(conn): drop_table(conn, 'pluto_18v2') pluto = nycdb.Dataset('pluto_18v2', args=ARGS) pluto.db_import() assert row_count(conn, 'pluto_18v2') == 10
def test_hpd_violations(conn): drop_table(conn, 'hpd_violations') hpd_violations = nycdb.Dataset('hpd_violations', args=ARGS) hpd_violations.db_import() assert row_count(conn, 'hpd_violations') == 100