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_dropTable_whatIfNotThere():
    set_DB_throwaway()
    DBcreate.DB_createTable()
    DBcreate.DB_dropTable()
    DBcreate.DB_dropTable()  # no problem, the IF EXISTS solves that

    assert True  # no return value; just check that it raised no exception
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_SQLfileIntoDB():
    set_DB_throwaway()
    delete_DB_and_SQL_file()

    DBcreate.DB_createTable()
    DBcreate.writeRowSQLIntoFile(block_example)

    conn = sqlite3.connect(DBcreate.DBFILE)
    DBcreate.SQLfileIntoDB(conn)
    conn.close()
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 test_DB_dropTable():
    set_DB_throwaway()
    DBcreate.DB_createTable()
    DBcreate.DB_dropTable()
    assert True  # no return value; just check that it raised no exception
def test_DB_createTable_ifAlreadyThere():
    set_DB_throwaway()
    DBcreate.DB_createTable()
    DBcreate.DB_createTable()  # the IF NOT EXISTS solves that problem

    assert True  # no return value; just check that it raised no exception