def test_final_status(): project0.fetchincidents(url) incidents = project0.extractincidents() project0.createdb() project0.populatedb(incidents) s = project0.status() assert type(s) == str
def test_table_check(): project0.fetchincidents(url) incidents = project0.extractincidents() project0.createdb() project0.populatedb(incidents) conn = sqlite3.connect('normanpd.db') c = conn.cursor() c.execute( "SELECT arrestee_name FROM arrests WHERE arrestee_birthday = '2/18/1999';" ) f = c.fetchone() assert type(f[0]) == str assert f[0] == 'CHASE LESLIE'
def test_status( ): temp_file = project0.fetchincidents(url) incidents = project0.extractincidents(temp_file) db = project0.createdb() project0.populatedb(db, incidents) result = project0.status(db) for i in result: assert len(i) > 0
def test_status(): data = project0.fetchincidents(url) incidents = project0.extractincidents(data) db = project0.createdb() project0.populatedb(db, incidents) s = project0.status(db) with open("test.txt", "w") as file: d = file.write(str(s)) # print (d) assert type(d) == int
def test_populatedb( ): temp_file = project0.fetchincidents(url) incidents = project0.extractincidents(temp_file) db = project0.createdb() project0.populatedb(db, incidents) database = sqlite3.connect(db) db = database.cursor() db.execute('select * from incidents;' ) result = db.fetchall() for i in result: assert len(i) == 5
def test_extract_num_of_pages(): data = project0.fetchincidents(url) incidents = project0.extractincidents(data) fp = tempfile.TemporaryFile() fp.write(data) fp.seek(0) pdf = PdfFileReader(fp) d = pdf.getNumPages() #print(d) # assert 0 assert d == 23
def test_populatedb(): data = project0.fetchincidents(url) incidents = project0.extractincidents(data) db = project0.createdb() project0.populatedb(db, incidents) con = sqlite3.connect("normanpd.db") cur = con.cursor() cur.execute( 'SELECT incident_location FROM incidents where nature="Traffic Stop";' ) row = cur.fetchall() assert row[0] == ('48TH AVE NE / E ROBINSON ST', )
def main(url): # Download data print("Here are the Arrest record URLs fetched from the Norman PD:\n") print(project0.fetchincidents(url)) print("\n") # Extract Data df = project0.extractincidents(project0.fetchincidents(url)) print( "\nHere are the first 5 records in the database stored from the Norman PD's arrest records:\n" ) print(df.head()) print("\n") # Create Dataase conn = project0.createdb() # Insert Data project0.populatedb(df, conn) # Print Status randomrecord = project0.status(conn) print(randomrecord[0]) type(randomrecord[0])
def test_page1_size(): text = project0.fetchincidents(url) fp = tempfile.TemporaryFile() fp.write(text) fp.seek(0) # Read the PDF pdfReader = PdfFileReader(fp) pdfReader.getNumPages() # Get the first page page1 = pdfReader.getPage(0).extractText() assert len(page1) == 2459
def main(url): # Download data incident_data = project0.fetchincidents(url) # Extract Data incidents = project0.extractincidents(incident_data) # Create Database db = project0.createdb() # Insert Data project0.populatedb(db, incidents) # Print Status project0.status(db)
def main(url): # Download data data_raw = project0.fetchincidents(url) # Extract Data incidents = project0.extractincidents(data_raw) # Create Dataase project0.createdb() # Insert Data project0.populatedb(incidents) # Print Status project0.status()
def test_populate_db(): text = project0.fetchincidents(url) incidents = project0.extractincidents(text) project0.createdb() conn = sqlite3.connect('normanpd.db') c = conn.cursor() No_of_obs = len(incidents) for i in range(0, No_of_obs - 1): c.execute("INSERT INTO arrests VALUES(?,?,?,?,?,?,?,?,?)", (incidents[i][0], incidents[i][1], incidents[i][2], incidents[i][3], incidents[i][4], incidents[i][5], incidents[i][6], incidents[i][7], incidents[i][8])) conn.commit() c.execute('SELECT COUNT(case_number)FROM arrests;') obs_populated = c.fetchone() obs_populated = obs_populated[0] assert obs_populated == 13
def test_fetchincidents(): assert project0.fetchincidents(url) is not None
def test_list_sanity(): assert project0.fetchincidents(url2) is not None
def test_download_size(): assert len(project0.fetchincidents(url)) == 30829
def test_extractincidents(): temp_file = project0.fetchincidents(url) result = project0.extractincidents(temp_file) for i in result: assert len(i) > 1
def test_count_observations(): text = project0.fetchincidents(url) observations = project0.extractincidents(text) assert len(observations) == 14
def test_extract_length(): data = project0.fetchincidents(url) incidents = project0.extractincidents(data) #extractincidents(data) assert len(incidents[0]) == 5
def test_download_sanity(): project0.fetchincidents(url) data = open('link.txt', 'rb') assert data is not None
def test_download(): data = project0.fetchincidents(url) assert data is not None
def test_list_size(): assert len(project0.fetchincidents(url2)) == 7
def test_extract_fields(): project0.fetchincidents(url) l = project0.extractincidents() assert len(l) == 15 assert len(l[0]) == 9