def test_DB_writeRow_duplicate():
    set_DB_throwaway()
    # DBcreate.DB_dropTable() # get rid of previous test's row
    DBcreate.DB_createTable()

    conn = sqlite3.connect(DBcreate.DBFILE)
    DBcreate.DB_writeRow(block_example, conn)
    # duplicate violates blocknumber UNIQUE constraint:
    with pytest.raises(sqlite3.IntegrityError):
        DBcreate.DB_writeRow(block_example, conn)
    conn.close()
def dummyDBconnection():
    set_DB_throwaway()
    delete_DB_and_SQL_file()
    DBcreate.DB_createTable()
    conn = sqlite3.connect(DBcreate.DBFILE)
    DBcreate.DB_writeRow(block_example, conn)
    return conn
def test_DB_writeRow():
    set_DB_throwaway()
    DBcreate.DB_createTable()

    conn = sqlite3.connect(DBcreate.DBFILE)
    DBcreate.DB_writeRow(block_example, conn)
    conn.close()

    assert True  # no return value; just check that it raised no exception
def test_DB_blocknumberMinMax():
    conn = dummyDBconnection()

    answer = DBcreate.DB_blocknumberMinMax(conn)
    print(answer)
    assert answer == [(1, 1)]

    block_example["number"] = 2
    print(block_example)
    DBcreate.DB_writeRow(block_example, conn)
    answer = DBcreate.DB_blocknumberMinMax(conn)
    print(answer)
    assert answer == [(1, 2)]

    conn.close()