Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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()