Exemple #1
0
def test_final_status():
    project0.fetchincidents(url)
    incidents = project0.extractincidents()
    project0.createdb()
    project0.populatedb(incidents)
    s = project0.status()
    assert type(s) == str
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
Exemple #3
0
def test_random_title():
    df = project0.extractincidents([url3])
    conn = project0.createdb()
    project0.populatedb(df, conn)
    randomrecord = project0.status(conn)

    assert randomrecord is not None
    assert len(randomrecord) == 9
    assert type(randomrecord[0]) == str
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_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', )
Exemple #7
0
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()
Exemple #8
0
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 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)
Exemple #10
0
def test_populate():
    df = project0.extractincidents([url3])
    conn = project0.createdb()
    project0.populatedb(df, conn)

    cursor = conn.cursor()
    cursor.execute("SELECT * FROM arrests")
    result = cursor.fetchone()
    assert result is not None
    assert result[0] == '2/9/2019 14:43'
    assert result[1] == '2019-00011057'
    assert result[2] == '2110 24TH AVE NW'
    assert result[3] == 'POSSESSION OF CDS'
    assert result[4] == 'BRADLEY SCOTT BUCHANAN'
    assert result[5] == '2/18/1979'
    assert result[6] == '2524 AGNEW AVE OKLAHOMA CITY OK 73108'
    assert result[7] == 'FDBDC (Jail)'
    assert result[8] == '0945 - Slater;'
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])