Exemple #1
0
def test_basket_countTotalPrice_buySomeBooks_ut():
    first_book = Book("Potter1", 8.0)
    second_book = Book("Potter2", 8.0)
    third_book = Book("Potter3", 8.0)
    fourth_book = Book("Potter4", 8.0)
    fifth_book = Book("Potter5", 8.0)

    basket = Basket()
    basket.addBook(first_book)
    basket.addBook(second_book)
    basket.addBook(third_book)
    basket.addBook(fourth_book)
    basket.addBook(fifth_book)

    basket.addBook(first_book)
    basket.addBook(second_book)
    basket.addBook(fourth_book)
    basket.addBook(fifth_book)

    basket.addBook(second_book)

    basket.sort_collection_of_books()

    total = 5 * 8.0 * 0.75 + 4 * 8.0 * 0.8 + 1 * 8.0 * 1

    assert total == basket.countTotalPrice()
Exemple #2
0
def test_basket_countTotalPrice_oneBooks_ut():

    basket = Basket()
    fifth_book = Book("Potter5", 8.0)
    basket.addBook(fifth_book)

    basket.sort_collection_of_books()

    assert 8.0 == basket.countTotalPrice()
Exemple #3
0
def test_basket_countTotalPrice_buyTwoThisSameBooks_noDiscount_ut():
    first_book = Book("Potter1", 8.0)

    basket = Basket()
    basket.addBook(first_book)
    basket.addBook(first_book)

    basket.sort_collection_of_books()

    assert basket.countTotalPrice() == 16.0
Exemple #4
0
def test_basket_countTotalPrice_buyTwoDifferentBooks_fivePercentOfDiscount_ut(
):
    first_book = Book("Potter1", 8.0)
    second_book = Book("Potter2", 8.0)

    basket = Basket()
    basket.addBook(first_book)
    basket.addBook(second_book)

    basket.sort_collection_of_books()

    assert basket.countTotalPrice() == 15.2
Exemple #5
0
def test_basket_countTotalPrice_buyThreeDifferentBooks_tenPercentOfDiscountut(
):
    first_book = Book("Potter1", 8.0)
    second_book = Book("Potter2", 8.0)
    third_book = Book("Potter3", 8.0)

    basket = Basket()
    basket.addBook(first_book)
    basket.addBook(second_book)
    basket.addBook(third_book)

    basket.sort_collection_of_books()

    assert 24.0 * 0.9 == basket.countTotalPrice()
Exemple #6
0
def test_basket_countTotalPrice_buyFiveDifferentBooks_25PercentOfDiscount_ut():
    first_book = Book("Potter1", 8.0)
    second_book = Book("Potter2", 8.0)
    third_book = Book("Potter3", 8.0)
    fourth_book = Book("Potter4", 8.0)
    fifth_book = Book("Potter5", 8.0)

    basket = Basket()
    basket.addBook(first_book)
    basket.addBook(second_book)
    basket.addBook(third_book)
    basket.addBook(fourth_book)
    basket.addBook(fifth_book)

    basket.sort_collection_of_books()

    assert 8.0 * 5 * 0.75 == basket.countTotalPrice()
Exemple #7
0
def test_basket_countTotalPrice_SpecialCase_ut():
    first_book = Book("Potter1", 8.0)
    second_book = Book("Potter2", 8.0)
    third_book = Book("Potter3", 8.0)
    fourth_book = Book("Potter4", 8.0)
    fifth_book = Book("Potter5", 8.0)

    basket = Basket()
    basket.addBook(first_book)
    basket.addBook(second_book)
    basket.addBook(third_book)
    basket.addBook(fourth_book)
    basket.addBook(fifth_book)

    basket.addBook(first_book)
    basket.addBook(second_book)
    basket.addBook(third_book)

    basket.sort_collection_of_books()

    total = 4 * 8.0 * 0.8 + 4 * 8.0 * 0.8

    assert total == basket.countTotalPrice()
Exemple #8
0
def test_basket_countTotalPrice_noBooks_ut():

    basket = Basket()
    basket.sort_collection_of_books()

    assert 0.0 == basket.countTotalPrice()