Пример #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
Пример #2
0
def test_populate_db():
    """
    Create a test object, insert it, and validate that we can get it out again
    """
    conn = main.createdb()
    in_ar = main.ArrestRecord(
        'test_datetime',
        'test_case_number',
        'test_arrests_location',
        'test_offense',
        'test_arrestee',
        'test_arrestee_birthday',
        'test_arrestee_address',
        'test_city',
        'test_state',
        'test_zip_code',
        'test_status',
        'test_officers',
    )
    main.populatedb(conn, [in_ar])
    # Test the total size
    assert conn.cursor().execute(
        'SELECT COUNT(*) FROM arrests').fetchone()[0] == 1
    # And that they match
    out = conn.cursor().execute('SELECT * FROM arrests LIMIT 1').fetchone()
    out_ar = main.ArrestRecord._make(out)
    assert out_ar == in_ar
    return conn
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
Пример #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
Пример #5
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