diff --git a/swap_meet/clothing.py b/swap_meet/clothing.py index b8afdeb1e..a6de15a84 100644 --- a/swap_meet/clothing.py +++ b/swap_meet/clothing.py @@ -1,2 +1,9 @@ -class Clothing: - pass \ No newline at end of file +from .item import Item + +class Clothing(Item): + def __init__(self, category = "Clothing", condition = 0, age = 0): + super().__init__(category, condition, age) + + + def __str__(self): + return "The finest clothing you could wear." \ No newline at end of file diff --git a/swap_meet/decor.py b/swap_meet/decor.py index eab7a9dbe..c2cded8c6 100644 --- a/swap_meet/decor.py +++ b/swap_meet/decor.py @@ -1,2 +1,9 @@ -class Decor: - pass \ No newline at end of file +from .item import Item + +class Decor(Item): + def __init__(self, category = "Decor", condition = 0, age = 0): + super().__init__(category, condition, age) + + + def __str__(self): + return "Something to decorate your space." \ No newline at end of file diff --git a/swap_meet/electronics.py b/swap_meet/electronics.py index 2f9dff68a..fc5e3b645 100644 --- a/swap_meet/electronics.py +++ b/swap_meet/electronics.py @@ -1,2 +1,9 @@ -class Electronics: - pass +from .item import Item + +class Electronics(Item): + def __init__(self, category = "Electronics", condition = 0, age = 0): + super().__init__(category, condition, age) + + + def __str__(self): + return "A gadget full of buttons and secrets." diff --git a/swap_meet/item.py b/swap_meet/item.py index 560d759c2..a44a85a8e 100644 --- a/swap_meet/item.py +++ b/swap_meet/item.py @@ -1,2 +1,31 @@ class Item: - pass \ No newline at end of file + def __init__(self, category = None, condition = 0, age = 0): + if not category: + category = "" + self.category = category + self.condition = condition + self.age = age + + + def __str__(self): + return "Hello World!" + + + def age_statement(self): + return f"This item was made {self.age} months ago." + + + def condition_description(self): + if self.condition == 0: + description = "horrendous quality" + elif self.condition == 1: + description = "terrible quality" + elif self.condition == 2: + description = "bad quality" + elif self.condition == 3: + description = "decent quality" + elif self.condition == 4: + description = "great quality" + elif self.condition == 5: + description = "exquisite quality" + return f"This item's condition is {description}" \ No newline at end of file diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index 87302c056..985721282 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -1,2 +1,102 @@ class Vendor: - pass \ No newline at end of file + def __init__(self, inventory = None): + if not inventory: + inventory = [] + self.inventory = inventory + + + def add(self, item): + self.inventory.append(item) + return item + + + def remove(self, item): + if item in self.inventory: + self.inventory.remove(item) + return item + return False + + + def get_by_category(self, category): + inventory_by_category = [] + for item in self.inventory: + if item.category == category: + inventory_by_category.append(item) + return inventory_by_category + + + def swap_items(self, other_vendor, my_item, their_item): + if my_item in self.inventory and their_item in other_vendor.inventory: + other_vendor.add(my_item) + self.remove(my_item) + self.add(their_item) + other_vendor.remove(their_item) + return True + return False + + + def swap_first_item(self, other_vendor): + try: + my_item = self.inventory[0] + their_item = other_vendor.inventory[0] + first_items = self.swap_items(other_vendor, my_item, their_item) + return first_items + except IndexError: + return False + + + def get_best_by_category(self, category): + max_condition = 0 + max_item = None + for item in self.inventory: + if item.condition > max_condition and item.category == category: + max_condition = item.condition + max_item = item + return max_item + + + def swap_best_by_category(self, other, my_priority, their_priority): + my_item = other.get_best_by_category(my_priority) + their_item = self.get_best_by_category(their_priority) + return self.swap_items(other, their_item, my_item) + + + +############### Optional Enhancement for Wave 07 ############### + def get_newest_item(self): + newest_age = 1000 + newest_item = None + for item in self.inventory: + if item.age < newest_age: + newest_age = item.age + newest_item = item + return newest_item + + + def swap_by_newest(self, other, my_item, their_item): + their_item = self.get_newest_item() + my_item = other.get_newest_item() + return self.swap_items(other, their_item, my_item) + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/integration_tests/test_wave_01_02_03.py b/tests/integration_tests/test_wave_01_02_03.py index 9912414da..9b2edbe81 100644 --- a/tests/integration_tests/test_wave_01_02_03.py +++ b/tests/integration_tests/test_wave_01_02_03.py @@ -2,8 +2,9 @@ from swap_meet.vendor import Vendor from swap_meet.item import Item -@pytest.mark.skip -@pytest.mark.integration_test +# Test 15 +#@pytest.mark.skip +#@pytest.mark.integration_test def test_integration_wave_01_02_03(): # make a vendor vendor = Vendor() diff --git a/tests/integration_tests/test_wave_04_05_06.py b/tests/integration_tests/test_wave_04_05_06.py index 4d0be9909..bc3ea5f61 100644 --- a/tests/integration_tests/test_wave_04_05_06.py +++ b/tests/integration_tests/test_wave_04_05_06.py @@ -4,8 +4,9 @@ from swap_meet.decor import Decor from swap_meet.electronics import Electronics -@pytest.mark.skip -@pytest.mark.integration_test +# Test 33 +# @pytest.mark.skip +# @pytest.mark.integration_test def test_integration_wave_04_05_06(): camila = Vendor() valentina = Vendor() diff --git a/tests/unit_tests/test_wave_01.py b/tests/unit_tests/test_wave_01.py index 58478ccf9..4510ea05c 100644 --- a/tests/unit_tests/test_wave_01.py +++ b/tests/unit_tests/test_wave_01.py @@ -2,12 +2,14 @@ import pytest from swap_meet.vendor import Vendor -@pytest.mark.skip +# Test 1 +#@pytest.mark.skip def test_vendor_has_inventory(): vendor = Vendor() assert len(vendor.inventory) == 0 -@pytest.mark.skip +# Test 2 +#@pytest.mark.skip def test_vendor_takes_optional_inventory(): inventory = ["a", "b", "c"] vendor = Vendor(inventory=inventory) @@ -16,18 +18,19 @@ def test_vendor_takes_optional_inventory(): assert "b" in vendor.inventory assert "c" in vendor.inventory -@pytest.mark.skip +# Test 3 +#@pytest.mark.skip def test_adding_to_inventory(): vendor = Vendor() item = "new item" - result = vendor.add(item) assert len(vendor.inventory) == 1 assert item in vendor.inventory assert result == item -@pytest.mark.skip +# Test 4 +#@pytest.mark.skip def test_removing_from_inventory_returns_item(): item = "item to remove" vendor = Vendor( @@ -39,8 +42,10 @@ def test_removing_from_inventory_returns_item(): assert len(vendor.inventory) == 3 assert item not in vendor.inventory assert result == item + -@pytest.mark.skip +# Test 5 +#@pytest.mark.skip def test_removing_not_found_is_false(): item = "item to remove" vendor = Vendor( @@ -49,7 +54,7 @@ def test_removing_not_found_is_false(): result = vendor.remove(item) - raise Exception("Complete this test according to comments below.") + #raise Exception("Complete this test according to comments below.") # ********************************************************************* - # ****** Complete Assert Portion of this test ********** + assert result == False # ********************************************************************* diff --git a/tests/unit_tests/test_wave_02.py b/tests/unit_tests/test_wave_02.py index 3d7060d7c..f59779166 100644 --- a/tests/unit_tests/test_wave_02.py +++ b/tests/unit_tests/test_wave_02.py @@ -2,12 +2,14 @@ from swap_meet.vendor import Vendor from swap_meet.item import Item -@pytest.mark.skip +# Test 6 +#@pytest.mark.skip def test_items_have_blank_default_category(): item = Item() assert item.category == "" -@pytest.mark.skip +# Test 7 +#@pytest.mark.skip def test_get_items_by_category(): item_a = Item(category="clothing") item_b = Item(category="electronics") @@ -23,7 +25,8 @@ def test_get_items_by_category(): assert item_c in items assert item_b not in items -@pytest.mark.skip +# Test 8 +#@pytest.mark.skip def test_get_no_matching_items_by_category(): item_a = Item(category="clothing") item_b = Item(category="clothing") @@ -34,7 +37,8 @@ def test_get_no_matching_items_by_category(): items = vendor.get_by_category("electronics") - raise Exception("Complete this test according to comments below.") + #raise Exception("Complete this test according to comments below.") # ********************************************************************* - # ****** Complete Assert Portion of this test ********** + assert items == [] + assert len(items) == 0 # ********************************************************************* diff --git a/tests/unit_tests/test_wave_03.py b/tests/unit_tests/test_wave_03.py index 0300b638f..0cfd0eead 100644 --- a/tests/unit_tests/test_wave_03.py +++ b/tests/unit_tests/test_wave_03.py @@ -2,7 +2,8 @@ from swap_meet.vendor import Vendor from swap_meet.item import Item -@pytest.mark.skip +# Test 9 +#@pytest.mark.skip def test_item_overrides_to_string(): item = Item() @@ -10,7 +11,8 @@ def test_item_overrides_to_string(): assert stringified_item == "Hello World!" -@pytest.mark.skip +# Test 10 +#@pytest.mark.skip def test_swap_items_returns_true(): item_a = Item(category="clothing") item_b = Item(category="clothing") @@ -38,7 +40,8 @@ def test_swap_items_returns_true(): assert item_b in jolie.inventory assert result -@pytest.mark.skip +# Test 11 +#@pytest.mark.skip def test_swap_items_when_my_item_is_missing_returns_false(): item_a = Item(category="clothing") item_b = Item(category="clothing") @@ -65,7 +68,8 @@ def test_swap_items_when_my_item_is_missing_returns_false(): assert item_e in jolie.inventory assert not result -@pytest.mark.skip +# Test 12 +#@pytest.mark.skip def test_swap_items_when_their_item_is_missing_returns_false(): item_a = Item(category="clothing") item_b = Item(category="clothing") @@ -92,7 +96,8 @@ def test_swap_items_when_their_item_is_missing_returns_false(): assert item_e in jolie.inventory assert not result -@pytest.mark.skip +# Test 13 +#@pytest.mark.skip def test_swap_items_from_my_empty_returns_false(): fatimah = Vendor( inventory=[] @@ -112,7 +117,8 @@ def test_swap_items_from_my_empty_returns_false(): assert len(jolie.inventory) == 2 assert not result -@pytest.mark.skip +# Test 14 +#@pytest.mark.skip def test_swap_items_from_their_empty_returns_false(): item_a = Item(category="clothing") item_b = Item(category="clothing") diff --git a/tests/unit_tests/test_wave_04.py b/tests/unit_tests/test_wave_04.py index 8190a4ebb..7e28cb0b9 100644 --- a/tests/unit_tests/test_wave_04.py +++ b/tests/unit_tests/test_wave_04.py @@ -2,7 +2,8 @@ from swap_meet.vendor import Vendor from swap_meet.item import Item -@pytest.mark.skip +# Test 16 +#@pytest.mark.skip def test_swap_first_item_returns_true(): item_a = Item(category="clothing") item_b = Item(category="clothing") @@ -30,7 +31,8 @@ def test_swap_first_item_returns_true(): assert item_a in jolie.inventory assert result -@pytest.mark.skip +# Test 17 +#@pytest.mark.skip def test_swap_first_item_from_my_empty_returns_false(): fatimah = Vendor( inventory=[] @@ -48,7 +50,8 @@ def test_swap_first_item_from_my_empty_returns_false(): assert len(jolie.inventory) == 2 assert not result -@pytest.mark.skip +# Test 18 +#@pytest.mark.skip def test_swap_first_item_from_their_empty_returns_false(): item_a = Item(category="clothing") item_b = Item(category="clothing") diff --git a/tests/unit_tests/test_wave_05.py b/tests/unit_tests/test_wave_05.py index 7abea06cd..d8dfec659 100644 --- a/tests/unit_tests/test_wave_05.py +++ b/tests/unit_tests/test_wave_05.py @@ -3,25 +3,29 @@ from swap_meet.decor import Decor from swap_meet.electronics import Electronics -@pytest.mark.skip +# Test 19 +#@pytest.mark.skip def test_clothing_has_default_category_and_to_str(): cloth = Clothing() assert cloth.category == "Clothing" assert str(cloth) == "The finest clothing you could wear." -@pytest.mark.skip +# Test 20 +#@pytest.mark.skip def test_decor_has_default_category_and_to_str(): decor = Decor() assert decor.category == "Decor" assert str(decor) == "Something to decorate your space." -@pytest.mark.skip +# Test 21 +#@pytest.mark.skip def test_electronics_has_default_category_and_to_str(): electronics = Electronics() assert electronics.category == "Electronics" assert str(electronics) == "A gadget full of buttons and secrets." -@pytest.mark.skip +# Test 22 +#@pytest.mark.skip def test_items_have_condition_as_float(): items = [ Clothing(condition=3.5), @@ -31,7 +35,8 @@ def test_items_have_condition_as_float(): for item in items: assert item.condition == pytest.approx(3.5) -@pytest.mark.skip +# Test 23 +#@pytest.mark.skip def test_items_have_condition_descriptions_that_are_the_same_regardless_of_type(): items = [ Clothing(condition=5), @@ -52,3 +57,20 @@ def test_items_have_condition_descriptions_that_are_the_same_regardless_of_type( assert item.condition_description() == one_condition_description assert one_condition_description != five_condition_description + + + #################################### +# Test 43(last)- Check for other condition values to obtain full code coverage +#@pytest.mark.skip +def test_condition_description_returns_correct_description_for_that_value(): + items = [ + Decor(condition=0), + Clothing(condition=1), + Electronics(condition=2), + Clothing(condition=3), + Decor(condition=4), + Electronics(condition=5) + ] + + for item in items: + assert item.condition_description() diff --git a/tests/unit_tests/test_wave_06.py b/tests/unit_tests/test_wave_06.py index 1f7065ab4..f98a027ee 100644 --- a/tests/unit_tests/test_wave_06.py +++ b/tests/unit_tests/test_wave_06.py @@ -4,7 +4,8 @@ from swap_meet.decor import Decor from swap_meet.electronics import Electronics -@pytest.mark.skip +# Test 24 +#@pytest.mark.skip def test_best_by_category(): item_a = Clothing(condition=2.0) item_b = Decor(condition=2.0) @@ -20,7 +21,8 @@ def test_best_by_category(): assert best_item.category == "Clothing" assert best_item.condition == pytest.approx(4.0) -@pytest.mark.skip +# Test 25 +#@pytest.mark.skip def test_best_by_category_no_matches_is_none(): item_a = Decor(condition=2.0) item_b = Decor(condition=2.0) @@ -33,7 +35,8 @@ def test_best_by_category_no_matches_is_none(): assert best_item is None -@pytest.mark.skip +# Test 26 +#@pytest.mark.skip def test_best_by_category_with_duplicates(): # Arrange item_a = Clothing(condition=2.0) @@ -50,10 +53,10 @@ def test_best_by_category_with_duplicates(): assert best_item.category == "Clothing" assert best_item.condition == pytest.approx(4.0) -@pytest.mark.skip +# Test 27 +#@pytest.mark.skip def test_swap_best_by_category(): # Arrange - # me item_a = Decor(condition=2.0) item_b = Electronics(condition=4.0) item_c = Decor(condition=4.0) @@ -61,7 +64,6 @@ def test_swap_best_by_category(): inventory=[item_a, item_b, item_c] ) - # them item_d = Clothing(condition=2.0) item_e = Decor(condition=4.0) item_f = Clothing(condition=4.0) @@ -76,16 +78,27 @@ def test_swap_best_by_category(): their_priority="Decor" ) - raise Exception("Complete this test according to comments below.") + #raise Exception("Complete this test according to comments below.") # ********************************************************************* - # ****** Complete Assert Portion of this test ********** + 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 # ********************************************************************* # Assertions should check: # - That the results is truthy # - That tai and jesse's inventories are the correct length # - That all the correct items are in tai and jesse's inventories, including the items which were swapped from one vendor to the other -@pytest.mark.skip +# Test 28 +#@pytest.mark.skip def test_swap_best_by_category_reordered(): # Arrange item_a = Decor(condition=2.0) @@ -109,16 +122,27 @@ def test_swap_best_by_category_reordered(): their_priority="Decor" ) - raise Exception("Complete this test according to comments below.") + #raise Exception("Complete this test according to comments below.") # ********************************************************************* - # ****** Complete Assert Portion of this test ********** + 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 # ********************************************************************* # Assertions should check: # - That result is truthy # - That tai and jesse's inventories are the correct length # - That all the correct items are in tai and jesse's inventories, and that the items that were swapped are not there -@pytest.mark.skip +# Test 29 +#@pytest.mark.skip def test_swap_best_by_category_no_inventory_is_false(): tai = Vendor( inventory=[] @@ -144,7 +168,8 @@ def test_swap_best_by_category_no_inventory_is_false(): assert item_b in jesse.inventory assert item_c in jesse.inventory -@pytest.mark.skip +# Test 30 +#@pytest.mark.skip def test_swap_best_by_category_no_other_inventory_is_false(): item_a = Clothing(condition=2.0) item_b = Decor(condition=4.0) @@ -170,7 +195,8 @@ def test_swap_best_by_category_no_other_inventory_is_false(): assert item_b in tai.inventory assert item_c in tai.inventory -@pytest.mark.skip +# Test 31 +#@pytest.mark.skip def test_swap_best_by_category_no_match_is_false(): # Arrange item_a = Decor(condition=2.0) @@ -194,16 +220,25 @@ def test_swap_best_by_category_no_match_is_false(): their_priority="Clothing" ) - raise Exception("Complete this test according to comments below.") + #raise Exception("Complete this test according to comments below.") # ********************************************************************* - # ****** Complete Assert Portion of this test ********** + 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 # ********************************************************************* # Assertions should check: # - That result is falsy # - That tai and jesse's inventories are the correct length # - That all the correct items are in tai and jesse's inventories -@pytest.mark.skip +# Test 32 +#@pytest.mark.skip def test_swap_best_by_category_no_other_match_is_false(): # Arrange item_a = Decor(condition=2.0) @@ -227,9 +262,17 @@ def test_swap_best_by_category_no_other_match_is_false(): their_priority="Decor" ) - raise Exception("Complete this test according to comments below.") + #raise Exception("Complete this test according to comments below.") # ********************************************************************* - # ****** Complete Assert Portion of this test ********** + 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 # ********************************************************************* # Assertions should check: # - That result is falsy diff --git a/tests/unit_tests/test_wave_07.py b/tests/unit_tests/test_wave_07.py new file mode 100644 index 000000000..21aac296a --- /dev/null +++ b/tests/unit_tests/test_wave_07.py @@ -0,0 +1,215 @@ +import pytest +from swap_meet.vendor import Vendor +from swap_meet.item import Item +from swap_meet.clothing import Clothing +from swap_meet.decor import Decor +from swap_meet.electronics import Electronics + +# Test 34 +#@pytest.mark.skip +def test_age_statement_by_default(): + item = Item() + item_age = item.age_statement() + + assert item.age == 0 + assert item_age == "This item was made 0 months ago." + + +# Test 35 +#@pytest.mark.skip +def test_age_statement_with_different_value(): + item = Item(age = 7) + item_age = item.age_statement() + + assert item_age == "This item was made 7 months ago." + + +# Test 36 +#@pytest.mark.skip +def test_get_newest_item(): + item_a = Clothing(age=1) + item_b = Decor(age=2) + item_c = Clothing(age=4) + item_d = Decor(age=5) + item_e = Clothing(age=3) + nishat = Vendor( + inventory=[item_a, item_b, item_c, item_d, item_e] + ) + + newest_item = nishat.get_newest_item() + + assert newest_item + assert newest_item.category == "Clothing" + assert newest_item.age == pytest.approx(1) + + +# Test 37 +#@pytest.mark.skip +def test_newest_item_is_empty(): + # item_a = Clothing(age=2) + # item_b = Decor(age=2) + # item_c = Clothing(age=4) + # item_d = Decor(age=5) + # item_e = Clothing(age=3) + nishat = Vendor( + inventory=[] + ) + + newest_item = nishat.get_newest_item() + + assert newest_item is None + + +# Test 38 +#@pytest.mark.skip +def test_get_newest_item_with_duplicates_returns_first_item(): + item_a = Clothing(age=2) + item_b = Decor(age=2) + item_c = Clothing(age=4) + item_d = Decor(age=5) + item_e = Clothing(age=3) + nishat = Vendor( + inventory=[item_a, item_b, item_c, item_d, item_e] + ) + + newest_item = nishat.get_newest_item() + + + assert newest_item.age == 2 + assert newest_item == item_a + + +# Test 39 +#@pytest.mark.skip +def test_swap_newest_item(): + # Arrange + item_a = Decor(age=12) + item_b = Electronics(age=8) + item_c = Decor(age=9) + nishat = Vendor( + inventory=[item_a, item_b, item_c] + ) + + item_d = Clothing(age=4) + item_e = Decor(age=7) + item_f = Clothing(age=14) + fatima = Vendor( + inventory=[item_d, item_e, item_f] + ) + + # Act + result = nishat.swap_by_newest( + other = fatima, + my_item = fatima.get_newest_item(), + their_item = nishat.get_newest_item() + ) + + assert result + assert len(nishat.inventory) == 3 + assert len(fatima.inventory) == 3 + assert item_a in nishat.inventory + assert item_b not in nishat.inventory + assert item_b in fatima.inventory + assert item_c in nishat.inventory + assert item_d not in fatima.inventory + assert item_d in nishat.inventory + assert item_e in fatima.inventory + assert item_f in fatima.inventory + + +# Test 40 +#@pytest.mark.skip +def test_swap_newest_item_reordered(): + # Arrange + item_a = Decor(age=12) + item_b = Electronics(age=8) + item_c = Decor(age=9) + nishat = Vendor( + inventory=[item_c, item_b, item_a] + ) + + item_d = Clothing(age=4) + item_e = Decor(age=7) + item_f = Clothing(age=14) + fatima = Vendor( + inventory=[item_e, item_d, item_f] + ) + + # Act + result = nishat.swap_by_newest( + other = fatima, + my_item = fatima.get_newest_item(), + their_item = nishat.get_newest_item() + ) + + assert result + assert len(nishat.inventory) == 3 + assert len(fatima.inventory) == 3 + assert item_a in nishat.inventory + assert item_b not in nishat.inventory + assert item_b in fatima.inventory + assert item_c in nishat.inventory + assert item_d not in fatima.inventory + assert item_d in nishat.inventory + assert item_e in fatima.inventory + assert item_f in fatima.inventory + + +# Test 41 +#@pytest.mark.skip +def test_swap_newest_item_self_inventory_empty(): + # Arrange + nishat = Vendor( + inventory=[] + ) + + item_d = Clothing(age=4) + item_e = Decor(age=7) + item_f = Clothing(age=14) + fatima = Vendor( + inventory=[item_d, item_e, item_f] + ) + + # Act + result = nishat.swap_by_newest( + other = fatima, + my_item = fatima.get_newest_item(), + their_item = nishat.get_newest_item() + ) + + assert not result + assert len(nishat.inventory) == 0 + assert len(fatima.inventory) == 3 + assert item_d in fatima.inventory + assert item_e in fatima.inventory + assert item_f in fatima.inventory + + +# Test 42 +#@pytest.mark.skip +def test_swap_newest_item_other_inventory_empty(): + # Arrange + item_a = Decor(age=12) + item_b = Electronics(age=8) + item_c = Decor(age=9) + nishat = Vendor( + inventory=[item_a, item_b, item_c] + ) + + fatima = Vendor( + inventory=[] + ) + + # Act + result = nishat.swap_by_newest( + other = fatima, + my_item = fatima.get_newest_item(), + their_item = nishat.get_newest_item() + ) + + assert not result + assert len(nishat.inventory) == 3 + assert len(fatima.inventory) == 0 + assert item_a in nishat.inventory + assert item_b in nishat.inventory + assert item_c in nishat.inventory \ No newline at end of file