import unittest
from library import cursor, db
class TestLibrary(unittest.TestCase):
def test_add_book(self):
cursor.execute(
"INSERT INTO books (title, author, year) VALUES (?, ?, ?)",
("Тестовая книга", "Тестовый автор", 2000)
)
db.commit()
cursor.execute(
"SELECT * FROM books WHERE title = ?",
("Тестовая книга",)
)
book = cursor.fetchone()
self.assertIsNotNone(book)
if __name__ == "__main__":
unittest.main()