def test_data_extract(): url = getUrl() data = project0.dataDownload(url) rows = project0.dataExtract(data) assert isinstance(rows, list) == True for i in range(len(rows)): assert isinstance(rows[i], list) == True assert len(rows[i]) == 9
def test_status(): url = getUrl() data = project0.dataDownload(url) rows = project0.dataExtract(data) dname = project0.dbCreate() project0.dbInsert(dname, rows) outRow = project0.dbStatus(dname) splitRow = outRow.split('\u00FE') assert isinstance(outRow, str) == True assert len(splitRow) == 9
def test_insert_data(): url = getUrl() data = project0.dataDownload(url) rows = project0.dataExtract(data) dname = project0.dbCreate() project0.dbInsert(dname, rows) dconn = sqlite3.connect(dname) dpoint = dconn.cursor() dpoint.execute('SELECT COUNT(*) FROM arrests;') inserted = dpoint.fetchone() assert inserted[0] == len(rows)
def main(url): #Download Data tempFile = project0.dataDownload(url) #Extract Data incidents = project0.dataExtract(tempFile) #Create Database db = project0.dbCreate() #Insert Data project0.dbInsert(db, incidents) #Print Status item = project0.dbStatus(db)
def test_data_download(): url = getUrl() data = project0.dataDownload(url) assert isinstance(data.read(), bytes) == True