def test_swap_best_by_category_reordered(): item_a = Decor(condition=2.0) item_b = Electronics(condition=4.0) item_c = Decor(condition=4.0) tai = Vendor(inventory=[item_c, item_b, item_a]) item_d = Clothing(condition=2.0) item_e = Decor(condition=4.0) item_f = Clothing(condition=4.0) jesse = Vendor(inventory=[item_f, item_e, item_d]) result = tai.swap_best_by_category(other=jesse, my_priority="Clothing", their_priority="Decor") assert result assert len(tai.inventory) == 3 assert len(jesse.inventory) == 3 assert item_a in tai.inventory assert item_b in tai.inventory assert item_c not in tai.inventory assert item_f in tai.inventory assert item_d in jesse.inventory assert item_e in jesse.inventory assert item_f not in jesse.inventory assert item_c in jesse.inventory
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
def test_swap_best_by_category_no_other_match2(): item_a = Clothing(condition=2.0) item_b = Decor(condition=4.0) item_c = Clothing(condition=4.0) item_d = Electronics(condition=4.0) tai = Vendor(inventory=[item_a, item_b, item_c]) jesse = Vendor(inventory=[item_d]) result = tai.swap_best_by_category(other=jesse, my_priority="Decor", their_priority="Clothing") assert result is False
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
def test_swap_best_by_category_no_inventory_is_false(): tai = Vendor(inventory=[]) item_a = Clothing(condition=2.0) item_b = Decor(condition=4.0) item_c = Clothing(condition=4.0) jesse = Vendor(inventory=[item_a, item_b, item_c]) result = tai.swap_best_by_category(other=jesse, my_priority="Clothing", their_priority="Decor") assert not result assert len(tai.inventory) == 0 assert len(jesse.inventory) == 3 assert item_a in jesse.inventory assert item_b in jesse.inventory assert item_c in jesse.inventory
def test_swap_best_by_category_no_match_is_false(): # tai = Vendor(inventory=[] # empty ) item_a = Clothing(condition=2.0) item_b = Decor(condition=4.0) item_c = Clothing(condition=4.0) jesse = Vendor(inventory=[item_a, item_b, item_c] # C2, D4, C4 ) result = tai.swap_best_by_category(other=jesse, my_priority="Clothing", their_priority="Decor") assert result is False assert len(tai.inventory) is 0 assert len(jesse.inventory) is 3 assert item_a in jesse.inventory assert item_b in jesse.inventory assert item_c in jesse.inventory
def test_swap_newest_by_category_no_other_inventory_is_false(): item_a = Decor(age=2) item_b = Electronics(age=1) item_c = Decor(age=1) 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 not result assert len(tai.inventory) == 3 assert len(jesse.inventory) == 0 assert item_a in tai.inventory assert item_b in tai.inventory assert item_c in tai.inventory
def test_swap_best_by_category_no_match_is_false(): 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="Clothing") assert not result assert len(tai.inventory) == 3 assert len(jesse.inventory) == 3 assert item_a in tai.inventory assert item_b in tai.inventory assert item_c in tai.inventory assert item_d in jesse.inventory assert item_e in jesse.inventory assert item_f in jesse.inventory