-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_library.py
More file actions
31 lines (25 loc) · 964 Bytes
/
test_library.py
File metadata and controls
31 lines (25 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pytest
from library import Library
from book import Book
import os
@pytest.fixture(autouse=True)
def cleanup():
yield
if os.path.exists("test_library.json"):
os.remove("test_library.json")
@pytest.fixture
def test_library():
return Library(storage_file="test_library.json")
# AŞAMA 1 ve 2 TESTİ: OOP ve Harici API entegrasyonu
# Bu test, Library sınıfının temel fonksiyonlarını (ekleme, silme, arama) ve harici API'den veri çekme özelliğini doğrular.
def test_add_and_remove_book(test_library):
assert len(test_library.books) == 0
test_isbn = "9780451526342"
test_library.add_book(test_isbn)
assert len(test_library.books) == 1
found_book = test_library.find_book(test_isbn)
assert found_book is not None
assert found_book.title == "Animal Farm"
test_library.remove_book(test_isbn)
assert len(test_library.books) == 0
assert test_library.find_book(test_isbn) is None