Ejemplo n.º 1
0
def test_status():
    result = main.fetchincidents(url)
    incidents = main.extractincidents(result)
    db = main.createdb()
    main.populatedb(db, incidents)
    y = main.status(db)
    assert type(y) == str
Ejemplo n.º 2
0
def test_populatedb():
    result = main.fetchincidents(url)
    incidents = main.extractincidents(result)
    conn = sqlite3.connect('normanpd.db')
    db = main.createdb()
    z = main.populatedb(db, incidents)
    assert z is not None
def test_populatedb():
    data = main.fetchincidents(
        "http://normanpd.normanok.gov/filebrowser_download/657/2020-02-24%20Daily%20Incident%20Summary.pdf"
    )
    conn = sqlite3.connect('NORMANPOLICE.db')
    c = conn.cursor()
    values = main.extractincidents(data)
    main.populatedb('NORMANPOLICE.db', values)
    row = "SELECT count(*) from incidents"
    assert c.execute(row).fetchall()[0][0] == 353
Ejemplo n.º 4
0
def test_createdb():

    result = main.fetchincidents(url)
    incidents = main.extractincidents(result)
    conn = sqlite3.connect('normanpd.db')
    db = main.createdb()
    main.populatedb(db, incidents)
    cursor = conn.cursor()
    x = cursor.execute(
        "SELECT name FROM sqlite_master WHERE type='table' AND name='{arrests}';"
    )
    assert x is not None
Ejemplo n.º 5
0
def test_insert_table():
    print("test_insert_table")
    dfdata = main.extractincidents(page1data)
    con = main.create_connection(database)
    main.create_table(con)
    main.insert_table(con , dfdata)
    com_len_rows = "SELECT COUNT(*) FROM arrests"
    cur = con.cursor()
    assert cur.execute(com_len_rows).fetchall()[0][0] == 10
    com = "PRAGMA table_info(arrests);"
    c = con.cursor()
    assert len(c.execute(com).fetchall()) == 9
Ejemplo n.º 6
0
def test_extractincidents():

    result = main.fetchincidents(url)
    incidents = main.extractincidents(result)
    assert main.extractincidents(result) is not None
Ejemplo n.º 7
0
def test_extractincidents():
    df = main.extractincidents(page1data)
    assert df is not None
    assert df.iloc[1][3] == "DRIVING WITH LIC. CANCELED/SUSPENDED/REVOKE D - DUS"
    assert df.shape == (10,9) # rows and cols
Ejemplo n.º 8
0
def test_extractincidents():
    url ="http://normanpd.normanok.gov/filebrowser_download/657/2020-02-24%20Daily%20Incident%20Summary.pdf"
    data=main.fetchincidents(url)
    tabledata=main.extractincidents(data)

    assert tabledata.shape == (353,5)
Ejemplo n.º 9
0
def test_extractincidents():
    page1data = main.fetchincidents(fileurl)
    assert main.extractincidents(page1data) is not None