Example #1
0
def test_swap_best_by_category_no_other_match():
    item_a = Clothing(condition=2.0)
    item_b = Decor(condition=4.0)
    item_c = Clothing(condition=4.0)
    tai = Vendor(inventory=[item_a, item_b, item_c])

    jesse = Vendor(inventory=[])

    result = tai.swap_best_by_category(other=jesse,
                                       my_priority="Decor",
                                       their_priority="Clothing")

    assert result is False
    assert len(tai.inventory) is 3
    assert len(jesse.inventory) is 0
    assert item_a in tai.inventory
    assert item_b in tai.inventory
    assert item_c in tai.inventory
Example #2
0
def test_swap_best_by_category():
    item_a = Decor(condition=2.0)
    item_b = Electronics(condition=4.0)
    item_c = Decor(condition=4.0)
    tai = Vendor(inventory=[item_a, item_b, item_c])

    item_d = Clothing(condition=2.0)
    item_e = Decor(condition=4.0)
    item_f = Clothing(condition=4.0)
    jesse = Vendor(inventory=[item_d, item_e, item_f])

    result = tai.swap_best_by_category(other=jesse,
                                       my_priority="Clothing",
                                       their_priority="Decor")

    assert result is True
    assert len(tai.inventory) is 3
    assert len(jesse.inventory) is 3
    assert item_c not in tai.inventory
    assert item_f in tai.inventory
    assert item_f not in jesse.inventory
    assert item_c in jesse.inventory