示例#1
0
def test_get_newest_by_category():
    item_a = Clothing(age=0)
    item_b = Decor(age=2)
    item_c = Clothing(age=3)
    item_d = Decor(age=1)
    item_e = Clothing(age=2)
    tai = Vendor(
        inventory=[item_a, item_b, item_c, item_d, item_e]
    )

    newest_clothing_item = tai.get_newest_by_category("Clothing")
    newest_decor_item = tai.get_newest_by_category("Decor")

    assert newest_clothing_item.category == "Clothing"
    assert newest_clothing_item.age == pytest.approx(0.0)
    assert newest_decor_item.category == "Decor"
    assert newest_decor_item.age == pytest.approx(1.0)
示例#2
0
def test_newest_by_category_no_matches_is_none():
    item_a = Decor(age=2.0)
    item_b = Decor(age=2.0)
    item_c = Decor(age=4.0)
    tai = Vendor(inventory=[item_a, item_b, item_c])

    newest_item = tai.get_newest_by_category("Electronics")

    assert newest_item is None
示例#3
0
def test_newest_by_category_with_duplicates():
    item_a = Clothing(age=2.0)
    item_b = Clothing(age=2.0)
    item_c = Clothing(age=4.0)
    tai = Vendor(inventory=[item_a, item_b, item_c])

    newest_item = tai.get_newest_by_category("Clothing")

    assert newest_item.category == "Clothing"
    assert newest_item.age == pytest.approx(2.0)
示例#4
0
def test_newest_by_category_no_matches_is_none():
    item_a = Decor(age=67)
    item_b = Decor(age=27)
    item_c = Decor(age=8)
    clara = Vendor(
        inventory=[item_a, item_b, item_c]
    )

    best_item = clara.get_newest_by_category("Electronics")

    assert best_item is None
示例#5
0
def test_newest_by_category():
    item_a = Clothing(age=2.0)
    item_b = Decor(age=3.0)
    item_c = Clothing(age=1.0)
    item_d = Decor(age=5.0)
    item_e = Clothing(age=3.0)
    tai = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e])

    newest_item = tai.get_newest_by_category("Clothing")

    assert newest_item.category == "Clothing"
    assert newest_item.age == pytest.approx(1.0)
def test_get_newest_by_category_with_duplicates():
    item_a = Clothing(age=2)
    item_b = Clothing(age=4)
    item_c = Clothing(age=4)
    tai = Vendor(
        inventory=[item_a, item_b, item_c]
    )

    best_item = tai.get_newest_by_category("Clothing")

    assert best_item.category == "Clothing"
    assert best_item.age == 4
示例#7
0
def test_newest_by_category_with_duplicates():
    item_a = Clothing(age=9)
    item_b = Clothing(age=6)
    item_c = Clothing(age=6)
    clara = Vendor(
        inventory=[item_a, item_b, item_c]
    )

    best_item = clara.get_newest_by_category("Clothing")

    assert best_item.category == "Clothing"
    assert best_item.age == pytest.approx(6)
def test_get_newest_by_category():
    item_a = Clothing(condition=None, age=2)
    item_b = Decor(condition=None, age=2)
    item_c = Clothing(condition=None, age=4)
    item_d = Decor(condition=None, age=5)
    item_e = Clothing(condition=None, age=3)
    tai = Vendor(
        inventory=[item_a, item_b, item_c, item_d, item_e]
    )

    best_item = tai.get_newest_by_category("Clothing")

    assert best_item.category == "Clothing"
    assert best_item.age == 4
示例#9
0
def test_newest_by_category():
    item_a = Clothing(age=17)
    item_b = Decor(age=23)
    item_c = Clothing(age=45)
    item_d = Decor(age=56)
    item_e = Clothing(age=37)
    clara = Vendor(
        inventory=[item_a, item_b, item_c, item_d, item_e]
    )

    best_item = clara.get_newest_by_category("Clothing")

    assert best_item.category == "Clothing"
    assert best_item.age == pytest.approx(17)