From 2a3d9b38ecb641306123f2cd43a0ac5fbef3ef4e Mon Sep 17 00:00:00 2001 From: Niambi Date: Wed, 5 Apr 2023 22:13:09 -0700 Subject: [PATCH 01/11] Added sudo code to item.py, party.py, & ran tests in test_wave_01_02_03.py to check for failures --- swap_meet/item.py | 28 ++++++++++++++- swap_meet/vendor.py | 34 ++++++++++++++++++- tests/integration_tests/test_wave_01_02_03.py | 2 +- 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/swap_meet/item.py b/swap_meet/item.py index 560d759c2..8ec799af9 100644 --- a/swap_meet/item.py +++ b/swap_meet/item.py @@ -1,2 +1,28 @@ +from uuid import (package) class Item: - pass \ No newline at end of file + def __init__(self, id,): + self.id = #unique int = unique int + self. + self. + + def + + def + + +# -------- WAVE 2 ------------- +#Each item in item class should have an attribute named id +#This attribute is a unique int +#use python's uuid package to help generate numbers without duplicates +#find which one of uuid's functions creates large unique numbers used as identifiers +# these functions will return uuid objects **(not int)** +# uuid objects have an attribute int which allows us ti access their value as an int +#when we intitialize and instance of items, we can optionally pass in an int with the keyword argument id to manually set the Items's id +#Each item will have a function mamed get_category +#Funciton will return a string holding the name of the class +#instances of vendor have an instance method get_by_id + +#---------- WAVE 3 ------------- + +# Create a method to stringify an item using str() using method swap_items +# \ No newline at end of file diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index 87302c056..a8a569224 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -1,2 +1,34 @@ class Vendor: - pass \ No newline at end of file + def __init__(self, id, inventory, add_item, remove_item): + self.id = id + self.inventory = [] + self.add_item = add_item + self.remove_item = remove_item + def add_item(): + return #item that was added + + def remove_item(): + return #item that was removed + + + + + + + +#each vendor will have an attribute named :inventory (an empty list) +#when we instantiate the instance of vendor, we can pass in a list with the argument inventory +#every instance of vendor has an instance menthod .add() +#.add() take is 1 item and adds it to inventory +#returns the item that was added +# every instance of vendor has a instance method .remove() +# .remove() takes in one item and removes matching item from inventory +#returns the item that was removed +#If no matching item found in inventory it returns False + +# ---------------- WAVE 2 -------------------- +#create get_by_id method +#instances of vendor have an instance method named get_by_id +#takes in one argument (int) which reps items id +#this method returns item with matching id from inventory +#if there is no item with matching id, the method should return None \ No newline at end of file diff --git a/tests/integration_tests/test_wave_01_02_03.py b/tests/integration_tests/test_wave_01_02_03.py index 0e521771a..0ab2cf96a 100644 --- a/tests/integration_tests/test_wave_01_02_03.py +++ b/tests/integration_tests/test_wave_01_02_03.py @@ -2,7 +2,7 @@ from swap_meet.vendor import Vendor from swap_meet.item import Item -@pytest.mark.skip +#@pytest.mark.skip @pytest.mark.integration_test def test_integration_wave_01_02_03(): # make a vendor From fb98fcbdf8a8e13d1f4227eb5a43ce1bcf478617 Mon Sep 17 00:00:00 2001 From: Niambi Date: Fri, 7 Apr 2023 00:46:25 -0700 Subject: [PATCH 02/11] Created functions and refactored code in item.py & party.py to pass wave_01 & wave_02 tests --- swap_meet/electronics.py | 11 +++++++- swap_meet/item.py | 40 ++++++++++------------------- swap_meet/vendor.py | 55 ++++++++++++++++++++++------------------ 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/swap_meet/electronics.py b/swap_meet/electronics.py index 2f9dff68a..33abee91d 100644 --- a/swap_meet/electronics.py +++ b/swap_meet/electronics.py @@ -1,2 +1,11 @@ class Electronics: - pass + def __init__(self, id, type, condition): + self.id = id + self.type = None + + def get_category(self): + return # + + #electronics = "Stereo" key="type" + + diff --git a/swap_meet/item.py b/swap_meet/item.py index 8ec799af9..5e850e1d8 100644 --- a/swap_meet/item.py +++ b/swap_meet/item.py @@ -1,28 +1,16 @@ -from uuid import (package) -class Item: - def __init__(self, id,): - self.id = #unique int = unique int - self. - self. - - def - - def +import uuid +class Item: + def __init__(self, id=None): + if id is None: + self.id = uuid.uuid4().int + else: + self.id = id + -# -------- WAVE 2 ------------- -#Each item in item class should have an attribute named id -#This attribute is a unique int -#use python's uuid package to help generate numbers without duplicates -#find which one of uuid's functions creates large unique numbers used as identifiers -# these functions will return uuid objects **(not int)** -# uuid objects have an attribute int which allows us ti access their value as an int -#when we intitialize and instance of items, we can optionally pass in an int with the keyword argument id to manually set the Items's id -#Each item will have a function mamed get_category -#Funciton will return a string holding the name of the class -#instances of vendor have an instance method get_by_id - -#---------- WAVE 3 ------------- - -# Create a method to stringify an item using str() using method swap_items -# \ No newline at end of file + def get_category(self): + return self.__class__.__name__ + + def get_by_id(self): + + return self.id # these functions will return uuid objects **(not int)** diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index a8a569224..e98bdbe80 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -1,31 +1,38 @@ +import uuid + class Vendor: - def __init__(self, id, inventory, add_item, remove_item): - self.id = id - self.inventory = [] - self.add_item = add_item - self.remove_item = remove_item - def add_item(): - return #item that was added + def __init__(self, id=None,inventory=[]): + self.id = uuid.uuid4().int + self.inventory = inventory #each vendor will have an attribute named :inventory (an empty list) + + def add(self, item): + self.inventory.append(item) + print(self.inventory) + print(item) + return item - def remove_item(): - return #item that was removed - - - - - + def remove(self, item): + #when this happens: remove takes in one item and removes matching item from inventory + # for current_item in self.inventory: + # if current_item == item: + # self.inventory.remove(item) + # return item #If no matching item found in inventory it returns False + # else: + # return False #item that was removed + if item not in self.inventory: + return False + else: + self.inventory.remove(item) + return item + def get_by_id(self, id): + return self.id -#each vendor will have an attribute named :inventory (an empty list) -#when we instantiate the instance of vendor, we can pass in a list with the argument inventory -#every instance of vendor has an instance menthod .add() -#.add() take is 1 item and adds it to inventory -#returns the item that was added -# every instance of vendor has a instance method .remove() -# .remove() takes in one item and removes matching item from inventory -#returns the item that was removed -#If no matching item found in inventory it returns False - +# vendor = Vendor() +# item = "new item" +# result = vendor.add(item) +# print(result) +# print(vendor.inventory) # ---------------- WAVE 2 -------------------- #create get_by_id method #instances of vendor have an instance method named get_by_id From 75c564aeafea37d56d95fc25618bce22661c8b1e Mon Sep 17 00:00:00 2001 From: Niambi Date: Fri, 7 Apr 2023 00:48:07 -0700 Subject: [PATCH 03/11] passed wave_01 tests & and the first 4 tests in wave_02 --- tests/integration_tests/test_wave_01_02_03.py | 3 ++- tests/unit_tests/test_wave_01.py | 15 ++++++--------- tests/unit_tests/test_wave_02.py | 12 ++++++------ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/tests/integration_tests/test_wave_01_02_03.py b/tests/integration_tests/test_wave_01_02_03.py index 0ab2cf96a..ebe3642ba 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.skip @pytest.mark.integration_test + def test_integration_wave_01_02_03(): # make a vendor vendor = Vendor() diff --git a/tests/unit_tests/test_wave_01.py b/tests/unit_tests/test_wave_01.py index 58478ccf9..fa13f8eb6 100644 --- a/tests/unit_tests/test_wave_01.py +++ b/tests/unit_tests/test_wave_01.py @@ -2,12 +2,12 @@ import pytest from swap_meet.vendor import Vendor -@pytest.mark.skip +#@pytest.mark.skip def test_vendor_has_inventory(): vendor = Vendor() assert len(vendor.inventory) == 0 -@pytest.mark.skip +#@pytest.mark.skip def test_vendor_takes_optional_inventory(): inventory = ["a", "b", "c"] vendor = Vendor(inventory=inventory) @@ -16,7 +16,7 @@ def test_vendor_takes_optional_inventory(): assert "b" in vendor.inventory assert "c" in vendor.inventory -@pytest.mark.skip +#@pytest.mark.skip def test_adding_to_inventory(): vendor = Vendor() item = "new item" @@ -27,7 +27,7 @@ def test_adding_to_inventory(): assert item in vendor.inventory assert result == item -@pytest.mark.skip +#@pytest.mark.skip def test_removing_from_inventory_returns_item(): item = "item to remove" vendor = Vendor( @@ -40,7 +40,7 @@ def test_removing_from_inventory_returns_item(): assert item not in vendor.inventory assert result == item -@pytest.mark.skip +#@pytest.mark.skip def test_removing_not_found_is_false(): item = "item to remove" vendor = Vendor( @@ -49,7 +49,4 @@ def test_removing_not_found_is_false(): result = vendor.remove(item) - 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 229165c75..67e774af6 100644 --- a/tests/unit_tests/test_wave_02.py +++ b/tests/unit_tests/test_wave_02.py @@ -2,30 +2,30 @@ from swap_meet.vendor import Vendor from swap_meet.item import Item -@pytest.mark.skip +#@pytest.mark.skip def test_items_have_default_uuid_length_id(): item = Item() assert isinstance(item.id, int) assert len(str(item.id)) >= 32 -@pytest.mark.skip +#@pytest.mark.skip def test_item_instances_have_different_default_ids(): item_a = Item() item_b = Item() assert item_a.id != item_b.id -@pytest.mark.skip +#@pytest.mark.skip def test_items_use_custom_id_if_passed(): item = Item(id=12345) assert isinstance(item.id, int) assert item.id == 12345 -@pytest.mark.skip +#@pytest.mark.skip def test_item_obj_returns_text_item_for_category(): item = Item() assert item.get_category() == "Item" -@pytest.mark.skip +#@pytest.mark.skip def test_get_item_by_id(): test_id = 12345 item_custom_id = Item(id=test_id) @@ -36,7 +36,7 @@ def test_get_item_by_id(): result_item = vendor.get_by_id(test_id) assert result_item is item_custom_id -@pytest.mark.skip +#@pytest.mark.skip def test_get_item_by_id_no_matching(): test_id = 12345 item_a = Item() From 6349fa629aed8c972ed665059d46f70c269afbec Mon Sep 17 00:00:00 2001 From: Niambi Date: Fri, 14 Apr 2023 16:05:41 -0700 Subject: [PATCH 04/11] updated get_item_by_id --- swap_meet/item.py | 16 ++++++++++--- swap_meet/vendor.py | 58 +++++++++++++++++++++++++++++---------------- 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/swap_meet/item.py b/swap_meet/item.py index 5e850e1d8..599547288 100644 --- a/swap_meet/item.py +++ b/swap_meet/item.py @@ -2,15 +2,25 @@ class Item: def __init__(self, id=None): + + # if id is not manually assigned if id is None: self.id = uuid.uuid4().int + #if id is manually assigned else: self.id = id - def get_category(self): return self.__class__.__name__ - def get_by_id(self): - return self.id # these functions will return uuid objects **(not int)** + + # def swap_meets(self, other_vendor, my_item, their_item): + # if not self.inventory(my_item) or not self.inventory(their_item): + # return False + # else: + # self.inventory.add(their_item) + # self.inventory.remove(my_item) + # #self.inventory.append(their_item) + # return True + # # these functions will return uuid objects **(not int)** diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index e98bdbe80..173903ba1 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -1,8 +1,7 @@ import uuid class Vendor: - def __init__(self, id=None,inventory=[]): - self.id = uuid.uuid4().int + def __init__(self, inventory=[]): self.inventory = inventory #each vendor will have an attribute named :inventory (an empty list) def add(self, item): @@ -12,13 +11,7 @@ def add(self, item): return item def remove(self, item): - #when this happens: remove takes in one item and removes matching item from inventory - # for current_item in self.inventory: - # if current_item == item: - # self.inventory.remove(item) - # return item #If no matching item found in inventory it returns False - # else: - # return False #item that was removed + if item not in self.inventory: return False else: @@ -26,16 +19,39 @@ def remove(self, item): return item def get_by_id(self, id): - return self.id + for item in self.inventory: + if item.id == id: + return item + else: + return None + +test_id = 12345 +item_custom_id = Item(id=test_id) +vendor = Vendor( + inventory=[Item(), Item(), item_custom_id] + ) + +result_item = vendor.get_by_id(test_id) +print(result_item) + + # def swap_first_item(self, other_vendor): + # if self.inventory(other_vendor) == None or self.inventory == None: + # return False + # else: + # #consider first item in instances inventory + # #consider first item in friends inventory + # #removes first item from this inventory andd adds it to friends + # # + # return True -# vendor = Vendor() -# item = "new item" -# result = vendor.add(item) -# print(result) -# print(vendor.inventory) -# ---------------- WAVE 2 -------------------- -#create get_by_id method -#instances of vendor have an instance method named get_by_id -#takes in one argument (int) which reps items id -#this method returns item with matching id from inventory -#if there is no item with matching id, the method should return None \ No newline at end of file + +# ---------------- WAVE 4 -------------------- +# In Wave 4 we will write one method, swap_first_item. + +# Instances of Vendor have an instance method named swap_first_item +# It takes one argument: an instance of another Vendor (other_vendor), representing the friend that the vendor is swapping with +# This method considers the first item in the instance's inventory, and the first item in the friend's inventory +# It removes the first item from its inventory, and adds the friend's first item +# It removes the first item from the friend's inventory, and adds the instances first item +# It returns True +# If either itself or the friend have an empty inventory, the method returns Fals From 8d8e193ced5f1c1fcdb58640378853ddee531080 Mon Sep 17 00:00:00 2001 From: Niambi Date: Fri, 14 Apr 2023 17:07:45 -0700 Subject: [PATCH 05/11] Adding print statements to debug test_wave_02 test_get_item_by_id --- swap_meet/item.py | 12 ++++++++---- swap_meet/vendor.py | 21 +++++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/swap_meet/item.py b/swap_meet/item.py index 599547288..244c32283 100644 --- a/swap_meet/item.py +++ b/swap_meet/item.py @@ -1,14 +1,18 @@ import uuid class Item: - def __init__(self, id=None): - - # if id is not manually assigned - if id is None: + def __init__(self, id=None): + print("id", id) + #if id is not manually assigned + if id == None: self.id = uuid.uuid4().int #if id is manually assigned else: self.id = id + # if id is not None: + # self.id = id + # else: + # self.id = uuid.uuid4().int def get_category(self): return self.__class__.__name__ diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index 173903ba1..8847886c9 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -1,4 +1,7 @@ -import uuid +import uuid + +from item import Item + class Vendor: def __init__(self, inventory=[]): @@ -20,19 +23,21 @@ def remove(self, item): def get_by_id(self, id): for item in self.inventory: + print(item.id) + print(id) if item.id == id: return item else: return None -test_id = 12345 -item_custom_id = Item(id=test_id) -vendor = Vendor( - inventory=[Item(), Item(), item_custom_id] - ) +# test_id = 12345 +# item_custom_id = Item(id=test_id) +# vendor = Vendor( +# inventory=[Item(), Item(), item_custom_id] +# ) -result_item = vendor.get_by_id(test_id) -print(result_item) +# result_item = vendor.get_by_id(test_id) +# print("result", result_item) # def swap_first_item(self, other_vendor): # if self.inventory(other_vendor) == None or self.inventory == None: From 61826f28df52bfa40b6738709a101b2026b2a18e Mon Sep 17 00:00:00 2001 From: Niambi Date: Fri, 14 Apr 2023 19:43:41 -0700 Subject: [PATCH 06/11] created method to stringify items in item.py & passed test_item_overrides_to_string in test_wave_03.py --- swap_meet/clothing.py | 29 ++++++++++++++++++++++++++++- swap_meet/decor.py | 13 ++++++++++++- swap_meet/electronics.py | 20 ++++++++++++++------ swap_meet/item.py | 8 +++----- swap_meet/vendor.py | 35 ++++++++++++++--------------------- 5 files changed, 71 insertions(+), 34 deletions(-) diff --git a/swap_meet/clothing.py b/swap_meet/clothing.py index b8afdeb1e..5e6a8bb9a 100644 --- a/swap_meet/clothing.py +++ b/swap_meet/clothing.py @@ -1,2 +1,29 @@ + + class Clothing: - pass \ No newline at end of file + pass +# def __init__(self, id=None, fabric="unknown"): +# self.id = uuid.uuid4().int +# self.fabric = fabric + +# def clothing(self): +# self.clothing = self.fabric + +# def get_category(self): +# return self.clothing + + + +# ------------------ WAVE 5 ----------------------- +# Clothing + +# Has an attribute id that is by default a unique integer +# Has an attribute fabric that is by default the string "Unknown" +# This attribute describes what fabric the clothing is made from; some example values might be "Striped", "Cotton", or "Floral" +# When we instantiate an instance of Clothing, we can optionally pass in a string with the keyword argument fabric +# Has a function get_category that returns "Clothing" +# Has a stringify method that returns "An object of type Clothing with id . It is made from fabric." + + + + \ No newline at end of file diff --git a/swap_meet/decor.py b/swap_meet/decor.py index eab7a9dbe..a9a89ece5 100644 --- a/swap_meet/decor.py +++ b/swap_meet/decor.py @@ -1,2 +1,13 @@ class Decor: - pass \ No newline at end of file + def __init__(self, condition=0): + self.conition = condition + + +# ------------------ WAVE 5 ----------------------- +# Has an attribute id that is by default a unique integer +# Holds 2 integer attributes width and length +# Both of these values should be 0 by default +# When we instantiate an instance of Decor, we can optionally pass in integers with the keyword arguments width and length +# Has a function get_category that returns "Decor" +# Has a stringify method that returns "An object of type Decor with id . It takes up a by sized space." +# For example, if we had a Decor instance with an id of 123435, width of 3, and length of 7, its stringify method should return "An object of type Decor with id 12345. It takes up a 3 by 7 sized space." \ No newline at end of file diff --git a/swap_meet/electronics.py b/swap_meet/electronics.py index 33abee91d..820de98db 100644 --- a/swap_meet/electronics.py +++ b/swap_meet/electronics.py @@ -1,11 +1,19 @@ class Electronics: - def __init__(self, id, type, condition): - self.id = id - self.type = None + pass +# def __init__(self, id, type, condition=0): +# self.id = id +# self.type = None - def get_category(self): - return # +# def get_category(self): +# return # - #electronics = "Stereo" key="type" +# #electronics = "Stereo" key="type" +# ------------------ WAVE 5 ----------------------- +# Has an attribute id that is by default a unique integer +# Has an attribute type that is by default the string "Unknown" +# This attribute describes what kind of electronic device this is. Some example values might be “Kitchen Appliance”, “Game Console”, or “Health Tracker” +# When we initialize an instance of Electronics, we can optionally pass in a string with the keyword argument type +# Has an function get_category that returns "Electronics" +# Has a stringify method that returns "An object of type Electronics with id . This is a device." diff --git a/swap_meet/item.py b/swap_meet/item.py index 244c32283..3e7106c44 100644 --- a/swap_meet/item.py +++ b/swap_meet/item.py @@ -9,15 +9,13 @@ def __init__(self, id=None): #if id is manually assigned else: self.id = id - # if id is not None: - # self.id = id - # else: - # self.id = uuid.uuid4().int + def get_category(self): return self.__class__.__name__ - + def __str__(self): + return f"An object of type {self.get_category()} with id {self.id}." # def swap_meets(self, other_vendor, my_item, their_item): # if not self.inventory(my_item) or not self.inventory(their_item): diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index 8847886c9..369c467b7 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -1,6 +1,6 @@ import uuid -from item import Item +#from item import Item class Vendor: @@ -27,27 +27,20 @@ def get_by_id(self, id): print(id) if item.id == id: return item - else: - return None - -# test_id = 12345 -# item_custom_id = Item(id=test_id) -# vendor = Vendor( -# inventory=[Item(), Item(), item_custom_id] -# ) - -# result_item = vendor.get_by_id(test_id) -# print("result", result_item) + return None + - # def swap_first_item(self, other_vendor): - # if self.inventory(other_vendor) == None or self.inventory == None: - # return False - # else: - # #consider first item in instances inventory - # #consider first item in friends inventory - # #removes first item from this inventory andd adds it to friends - # # - # return True + def swap_first_item(self, other_vendor): + + + if self.inventory(other_vendor) == None or self.inventory == None: + return False + else: + #consider first item in instances inventory + #consider first item in friends inventory + #removes first item from this inventory andd adds it to friends + # + return True # ---------------- WAVE 4 -------------------- From fd22cec6c836d528b42b3e6be185425f45f28d8b Mon Sep 17 00:00:00 2001 From: Niambi Date: Fri, 14 Apr 2023 20:58:14 -0700 Subject: [PATCH 07/11] modified swap_items to pass remainder of wave_03 tests --- swap_meet/item.py | 10 +--------- swap_meet/vendor.py | 34 ++++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/swap_meet/item.py b/swap_meet/item.py index 3e7106c44..619a1991e 100644 --- a/swap_meet/item.py +++ b/swap_meet/item.py @@ -17,12 +17,4 @@ def get_category(self): def __str__(self): return f"An object of type {self.get_category()} with id {self.id}." - # def swap_meets(self, other_vendor, my_item, their_item): - # if not self.inventory(my_item) or not self.inventory(their_item): - # return False - # else: - # self.inventory.add(their_item) - # self.inventory.remove(my_item) - # #self.inventory.append(their_item) - # return True - # # these functions will return uuid objects **(not int)** + \ No newline at end of file diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index 369c467b7..4105ac16c 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -28,19 +28,33 @@ def get_by_id(self, id): if item.id == id: return item return None - - - def swap_first_item(self, other_vendor): - - if self.inventory(other_vendor) == None or self.inventory == None: + + def swap_items(self, other_vendor, my_item, their_item): + if not my_item in self.inventory or not their_item in other_vendor.inventory: return False else: - #consider first item in instances inventory - #consider first item in friends inventory - #removes first item from this inventory andd adds it to friends - # - return True + self.remove(my_item) + self.add(their_item) + other_vendor.remove(their_item) + other_vendor.add(my_item) + return True + # these functions will return uuid objects **(not int)** + + + + + + +# def swap +# if self.inventory(other_vendor) == None or self.inventory(my_item) == None: +# return False +# else: +# #consider first item in instances inventory +# #consider first item in friends inventory +# #removes first item from this inventory andd adds it to friends +# # +# return True # ---------------- WAVE 4 -------------------- From 1e5afeb36d9d1dfc2604a33aeef7d900b18e1155 Mon Sep 17 00:00:00 2001 From: Niambi Date: Sat, 15 Apr 2023 03:50:24 -0700 Subject: [PATCH 08/11] created & modified function swap_first_item to pass wave_03 tests: test_swap_first_item_from_my_empty_returns_false & test_swap_first_item_from_their_empty_return_false. --- swap_meet/clothing.py | 19 +++++++++++-------- swap_meet/vendor.py | 24 ++++++++++-------------- tests/unit_tests/test_wave_03.py | 19 +++++++++---------- tests/unit_tests/test_wave_04.py | 6 +++--- 4 files changed, 33 insertions(+), 35 deletions(-) diff --git a/swap_meet/clothing.py b/swap_meet/clothing.py index 5e6a8bb9a..bcdf84e7d 100644 --- a/swap_meet/clothing.py +++ b/swap_meet/clothing.py @@ -1,16 +1,19 @@ class Clothing: - pass -# def __init__(self, id=None, fabric="unknown"): -# self.id = uuid.uuid4().int -# self.fabric = fabric -# def clothing(self): -# self.clothing = self.fabric + def __init__(self, id=None, fabric="unknown"): + self.id = uuid.uuid4().int + if not fabric == "unknown": + self.fabric = fabric + else: + self.fabric = user_input -# def get_category(self): -# return self.clothing + def clothing(self): + self.clothing = self.fabric + + def get_category(self): + return self.clothing diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index 4105ac16c..a6ae0860b 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -41,20 +41,16 @@ def swap_items(self, other_vendor, my_item, their_item): return True # these functions will return uuid objects **(not int)** - - - - - -# def swap -# if self.inventory(other_vendor) == None or self.inventory(my_item) == None: -# return False -# else: -# #consider first item in instances inventory -# #consider first item in friends inventory -# #removes first item from this inventory andd adds it to friends -# # -# return True + def swap_first_item(self, other_vendor): + if other_vendor.inventory == [] or self.inventory == []: + return False + else: + #look at the syntax here + self.remove(self.inventory[0]) + other_vendor.remove(other_vendor.inventory[0]) + other_vendor.add(self.inventory[0]) + self.add(other_vendor.inventory[0]) + return True # ---------------- WAVE 4 -------------------- diff --git a/tests/unit_tests/test_wave_03.py b/tests/unit_tests/test_wave_03.py index c85da6797..07e73a640 100644 --- a/tests/unit_tests/test_wave_03.py +++ b/tests/unit_tests/test_wave_03.py @@ -2,7 +2,7 @@ from swap_meet.vendor import Vendor from swap_meet.item import Item -@pytest.mark.skip +#@pytest.mark.skip def test_item_overrides_to_string(): test_id = 12345 item = Item(id=test_id) @@ -12,7 +12,7 @@ def test_item_overrides_to_string(): expected_result = f"An object of type Item with id {test_id}." assert item_as_string == expected_result -@pytest.mark.skip +#@pytest.mark.skip def test_swap_items_returns_true(): item_a = Item() item_b = Item() @@ -40,7 +40,7 @@ def test_swap_items_returns_true(): assert item_b in jolie.inventory assert result -@pytest.mark.skip +#@pytest.mark.skip def test_swap_items_when_my_item_is_missing_returns_false(): item_a = Item() item_b = Item() @@ -67,7 +67,7 @@ def test_swap_items_when_my_item_is_missing_returns_false(): assert item_e in jolie.inventory assert not result -@pytest.mark.skip +#@pytest.mark.skip def test_swap_items_when_their_item_is_missing_returns_false(): item_a = Item() item_b = Item() @@ -94,7 +94,7 @@ def test_swap_items_when_their_item_is_missing_returns_false(): assert item_e in jolie.inventory assert not result -@pytest.mark.skip +#@pytest.mark.skip def test_swap_items_from_my_empty_returns_false(): fatimah = Vendor( inventory=[] @@ -114,7 +114,7 @@ def test_swap_items_from_my_empty_returns_false(): assert len(jolie.inventory) == 2 assert not result -@pytest.mark.skip +#@pytest.mark.skip def test_swap_items_from_their_empty_returns_false(): item_a = Item() item_b = Item() @@ -131,7 +131,6 @@ def test_swap_items_from_their_empty_returns_false(): result = fatimah.swap_items(jolie, item_b, nobodys_item) - raise Exception("Complete this test according to comments below.") - # ********************************************************************* - # ****** Complete Assert Portion of this test ********** - # ********************************************************************* + assert len(fatimah.inventory) == 3 + assert len(jolie.inventory) == 0 + assert not result \ No newline at end of file diff --git a/tests/unit_tests/test_wave_04.py b/tests/unit_tests/test_wave_04.py index 87addbbf6..3d1433d1d 100644 --- a/tests/unit_tests/test_wave_04.py +++ b/tests/unit_tests/test_wave_04.py @@ -2,7 +2,7 @@ from swap_meet.vendor import Vendor from swap_meet.item import Item -@pytest.mark.skip +#@pytest.mark.skip def test_swap_first_item_returns_true(): item_a = Item() item_b = Item() @@ -30,7 +30,7 @@ def test_swap_first_item_returns_true(): assert item_a in jolie.inventory assert result -@pytest.mark.skip +#@pytest.mark.skip def test_swap_first_item_from_my_empty_returns_false(): fatimah = Vendor( inventory=[] @@ -48,7 +48,7 @@ def test_swap_first_item_from_my_empty_returns_false(): assert len(jolie.inventory) == 2 assert not result -@pytest.mark.skip +#@pytest.mark.skip def test_swap_first_item_from_their_empty_returns_false(): item_a = Item() item_b = Item() From abc7e26a357aa9542fa44f3889488abf8fe9d9f0 Mon Sep 17 00:00:00 2001 From: Niambi Date: Sat, 15 Apr 2023 23:23:52 -0700 Subject: [PATCH 09/11] Began writing instance methods for wave_05 classes and refactoring code so classes can inherit items attributes. --- swap_meet/clothing.py | 40 ++++++++++++++------------------ swap_meet/decor.py | 14 ++++++++--- swap_meet/electronics.py | 21 ++++++++++------- swap_meet/item.py | 5 ++-- swap_meet/vendor.py | 23 +++++++++--------- tests/unit_tests/test_wave_05.py | 28 +++++++++++----------- 6 files changed, 70 insertions(+), 61 deletions(-) diff --git a/swap_meet/clothing.py b/swap_meet/clothing.py index bcdf84e7d..75bca6a07 100644 --- a/swap_meet/clothing.py +++ b/swap_meet/clothing.py @@ -1,32 +1,26 @@ +from swap_meet.item import Item +class Clothing(Item): + # May have to change fabric default values to None + def __init__(self, id, fabric="unknown"): + super().__init__(id) + if fabric == None: + self.fabric = "unknown" -class Clothing: - - def __init__(self, id=None, fabric="unknown"): - self.id = uuid.uuid4().int - if not fabric == "unknown": - self.fabric = fabric else: - self.fabric = user_input - + self.fabric = fabric + def clothing(self): - self.clothing = self.fabric + self.clothing = self.fabric def get_category(self): return self.clothing + def __str__(self): + if self.fabric == "unknown": + return f"An object of type {self.get_category()} with id {self.id}. It is made from Unknown fabric." + else: + return f"An object of type {self.clothing()} with id {self.id}. It is made from {self.fabric} fabric." - -# ------------------ WAVE 5 ----------------------- -# Clothing - -# Has an attribute id that is by default a unique integer -# Has an attribute fabric that is by default the string "Unknown" -# This attribute describes what fabric the clothing is made from; some example values might be "Striped", "Cotton", or "Floral" -# When we instantiate an instance of Clothing, we can optionally pass in a string with the keyword argument fabric -# Has a function get_category that returns "Clothing" -# Has a stringify method that returns "An object of type Clothing with id . It is made from fabric." - - - - \ No newline at end of file + def condition_description(self): + pass \ No newline at end of file diff --git a/swap_meet/decor.py b/swap_meet/decor.py index a9a89ece5..e9cb88803 100644 --- a/swap_meet/decor.py +++ b/swap_meet/decor.py @@ -1,7 +1,15 @@ -class Decor: - def __init__(self, condition=0): - self.conition = condition +from swap_meet.item import Item +class Decor (Item): + def __init__(self, condition=0, width, length): + super().__init__(id) + self.condition = condition + self.width = width + self.length = length + + + def condition_description(self): + pass # ------------------ WAVE 5 ----------------------- # Has an attribute id that is by default a unique integer diff --git a/swap_meet/electronics.py b/swap_meet/electronics.py index 820de98db..694a0cce7 100644 --- a/swap_meet/electronics.py +++ b/swap_meet/electronics.py @@ -1,13 +1,18 @@ -class Electronics: - pass -# def __init__(self, id, type, condition=0): -# self.id = id -# self.type = None +from swap_meet.item import Item -# def get_category(self): -# return # +class Electronics(Item): + def __init__(self, type, condition=0): + super().__init__(id) + self.type = None + self.condition = condition + + def get_category(self): + pass -# #electronics = "Stereo" key="type" + def condition_description(self): + pass + + #electronics = "Stereo" key="type" # ------------------ WAVE 5 ----------------------- diff --git a/swap_meet/item.py b/swap_meet/item.py index 619a1991e..70faca413 100644 --- a/swap_meet/item.py +++ b/swap_meet/item.py @@ -2,7 +2,6 @@ class Item: def __init__(self, id=None): - print("id", id) #if id is not manually assigned if id == None: self.id = uuid.uuid4().int @@ -17,4 +16,6 @@ def get_category(self): def __str__(self): return f"An object of type {self.get_category()} with id {self.id}." - \ No newline at end of file + + def condition_description(self): + return f"{self.get_category()} heavily used. Condition rated 0." \ No newline at end of file diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index a6ae0860b..74ce582b9 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -51,15 +51,16 @@ def swap_first_item(self, other_vendor): other_vendor.add(self.inventory[0]) self.add(other_vendor.inventory[0]) return True + # ERROR: assert item_d in fatimah.inventory + #item_a = Item() + # item_b = Item() + # item_c = Item() + # fatimah = Vendor( + # inventory=[item_a, item_b, item_c] + # ) - -# ---------------- WAVE 4 -------------------- -# In Wave 4 we will write one method, swap_first_item. - -# Instances of Vendor have an instance method named swap_first_item -# It takes one argument: an instance of another Vendor (other_vendor), representing the friend that the vendor is swapping with -# This method considers the first item in the instance's inventory, and the first item in the friend's inventory -# It removes the first item from its inventory, and adds the friend's first item -# It removes the first item from the friend's inventory, and adds the instances first item -# It returns True -# If either itself or the friend have an empty inventory, the method returns Fals + # item_d = Item() + # item_e = Item() + # jolie = Vendor( + # inventory=[item_d, item_e] + # ) \ No newline at end of file diff --git a/tests/unit_tests/test_wave_05.py b/tests/unit_tests/test_wave_05.py index 46e208237..7c012249a 100644 --- a/tests/unit_tests/test_wave_05.py +++ b/tests/unit_tests/test_wave_05.py @@ -7,17 +7,17 @@ # ~~~~~ Clothing Tests ~~~~~ -@pytest.mark.skip +#@pytest.mark.skip def test_clothing_has_default_uuid_length_id(): clothing = Clothing() check_for_default_uuid_length_id(clothing) -@pytest.mark.skip +#@pytest.mark.skip def test_clothing_has_expected_category_and_custom_id(): clothing = Clothing(id=TEST_CUSTOM_ID) check_category_and_custom_id(clothing, TEST_CUSTOM_ID, "Clothing") -@pytest.mark.skip +#@pytest.mark.skip def test_clothing_has_expected_default_to_str(): clothing = Clothing(id=TEST_CUSTOM_ID) expected_str = ( @@ -26,7 +26,7 @@ def test_clothing_has_expected_default_to_str(): ) assert str(clothing) == expected_str -@pytest.mark.skip +#@pytest.mark.skip def test_clothing_has_expected_to_str_with_custom_fabric(): clothing = Clothing(id=TEST_CUSTOM_ID, fabric="Pinstriped") expected_str = ( @@ -37,17 +37,17 @@ def test_clothing_has_expected_to_str_with_custom_fabric(): # ~~~~~ Decor Tests ~~~~~ -@pytest.mark.skip +#@pytest.mark.skip def test_decor_has_default_uuid_length_id(): decor = Decor() check_for_default_uuid_length_id(decor) -@pytest.mark.skip +#@pytest.mark.skip def test_decor_has_expected_category_and_custom_id(): decor = Decor(id=TEST_CUSTOM_ID) check_category_and_custom_id(decor, TEST_CUSTOM_ID, "Decor") -@pytest.mark.skip +#@pytest.mark.skip def test_decor_has_expected_default_to_str(): decor = Decor(id=TEST_CUSTOM_ID) expected_str = ( @@ -56,7 +56,7 @@ def test_decor_has_expected_default_to_str(): ) assert str(decor) == expected_str -@pytest.mark.skip +#@pytest.mark.skip def test_decor_has_expected_to_str_with_custom_size(): decor = Decor(id=TEST_CUSTOM_ID, width=3, length=12) expected_str = ( @@ -67,17 +67,17 @@ def test_decor_has_expected_to_str_with_custom_size(): # ~~~~~ Electronics Tests ~~~~~ -@pytest.mark.skip +#@pytest.mark.skip def test_electronics_has_default_uuid_length_id(): electronics = Electronics() check_for_default_uuid_length_id(electronics) -@pytest.mark.skip +#@pytest.mark.skip def test_electronics_has_expected_category_and_custom_id(): electronics = Electronics(id=TEST_CUSTOM_ID) check_category_and_custom_id(electronics, TEST_CUSTOM_ID, "Electronics") -@pytest.mark.skip +#@pytest.mark.skip def test_electronics_has_expected_default_to_str(): electronics = Electronics(id=TEST_CUSTOM_ID) expected_str = ( @@ -86,7 +86,7 @@ def test_electronics_has_expected_default_to_str(): ) assert str(electronics) == expected_str -@pytest.mark.skip +#@pytest.mark.skip def test_electronics_has_expected_to_str_with_custom_type(): electronics = Electronics(id=TEST_CUSTOM_ID, type="Mobile Phone") expected_str = ( @@ -98,7 +98,7 @@ def test_electronics_has_expected_to_str_with_custom_type(): # ~~~~~ Item Tests ~~~~~ -@pytest.mark.skip +#@pytest.mark.skip def test_items_have_condition_as_float(): items = [ Clothing(condition=3.5), @@ -108,7 +108,7 @@ def test_items_have_condition_as_float(): for item in items: assert item.condition == pytest.approx(3.5) -@pytest.mark.skip +#@pytest.mark.skip def test_items_have_condition_descriptions_that_are_the_same_regardless_of_type(): items = [ Clothing(condition=5), From 16fb58b781eb18c77a1a31a3eae98d53e621d8c0 Mon Sep 17 00:00:00 2001 From: Niambi Date: Sun, 16 Apr 2023 20:18:04 -0700 Subject: [PATCH 10/11] Created 3 modules for wave 5, applied inheritance from item class, & passed all wave_05 tests. --- swap_meet/clothing.py | 34 +++++++++++++++++++++++----------- swap_meet/decor.py | 24 ++++++++++++++++++++---- swap_meet/electronics.py | 27 ++++++++++++++++++++------- swap_meet/item.py | 19 +++++++++++++++---- 4 files changed, 78 insertions(+), 26 deletions(-) diff --git a/swap_meet/clothing.py b/swap_meet/clothing.py index 75bca6a07..b74679006 100644 --- a/swap_meet/clothing.py +++ b/swap_meet/clothing.py @@ -2,25 +2,37 @@ class Clothing(Item): # May have to change fabric default values to None - def __init__(self, id, fabric="unknown"): - super().__init__(id) + def __init__(self, id=None, fabric="Unknown", condition=0): + super().__init__(id, condition) if fabric == None: - self.fabric = "unknown" - + self.fabric = "Unknown" else: self.fabric = fabric def clothing(self): - self.clothing = self.fabric + self.clothing = self.fabric def get_category(self): - return self.clothing + return "Clothing" def __str__(self): - if self.fabric == "unknown": - return f"An object of type {self.get_category()} with id {self.id}. It is made from Unknown fabric." - else: - return f"An object of type {self.clothing()} with id {self.id}. It is made from {self.fabric} fabric." + return f"An object of type {self.get_category()} with id {self.id}. It is made from {self.fabric} fabric." + # if self.fabric == "unknown": + # return f"An object of type {self.get_category()} with id {self.id}. It is made from Unknown fabric." + # else: + # return f"An object of type {self.clothing()} with id {self.id}. It is made from {self.fabric} fabric." + def condition_description(self): - pass \ No newline at end of file + if self.condition == 0: + return f"Item condition is rated 0. This item is barely holding on!" + elif self.condition == 1: + return f"Items condition is rated 1. This item is hanging on by a thread!" + elif self.condition == 2: + return f"Items condition is rated 2. This item is living on a prayer." + elif self.condition == 3: + return f"Items condition is rated 3. This item is in working order." + elif self.condition == 4: + return f"Items condition is rated 4. This item is in good condition." + else: + return f"Items condition is rated 5. This item is in excellent condition." \ No newline at end of file diff --git a/swap_meet/decor.py b/swap_meet/decor.py index e9cb88803..fd0a5e148 100644 --- a/swap_meet/decor.py +++ b/swap_meet/decor.py @@ -1,15 +1,31 @@ from swap_meet.item import Item class Decor (Item): - def __init__(self, condition=0, width, length): - super().__init__(id) - self.condition = condition + def __init__(self, id=None, condition=0, width=0, length=0): + super().__init__(id, condition) self.width = width self.length = length def condition_description(self): - pass + if self.condition == 0: + return f"Item condition is rated 0. This item is barely holding on!" + elif self.condition == 1: + return f"Items condition is rated 1. This item is hanging on by a thread!" + elif self.condition == 2: + return f"Items condition is rated 2. This item is living on a prayer." + elif self.condition == 3: + return f"Items condition is rated 3. This item is in working order." + elif self.condition == 4: + return f"Items condition is rated 4. This item is in good condition." + else: + return f"Items condition is rated 5. This item is in excellent condition." + + def get_category(self): + return self.__class__.__name__ + + def __str__(self): + return f"An object of type {self.get_category()} with id {self.id}. It takes up a {self.width} by {self.length} sized space." # ------------------ WAVE 5 ----------------------- # Has an attribute id that is by default a unique integer diff --git a/swap_meet/electronics.py b/swap_meet/electronics.py index 694a0cce7..b1284a567 100644 --- a/swap_meet/electronics.py +++ b/swap_meet/electronics.py @@ -1,17 +1,30 @@ from swap_meet.item import Item class Electronics(Item): - def __init__(self, type, condition=0): - super().__init__(id) - self.type = None - self.condition = condition + def __init__(self, id=None, type="Unknown", condition=0): + super().__init__(id, condition) + self.type = type def get_category(self): - pass + return self.__class__.__name__ + + def __str__(self): + return f"An object of type {self.get_category()} with id {self.id}. This is a {self.type} device." def condition_description(self): - pass - + if self.condition == 0: + return f"Item condition is rated 0. This item is barely holding on!" + elif self.condition == 1: + return f"Items condition is rated 1. This item is hanging on by a thread!" + elif self.condition == 2: + return f"Items condition is rated 2. This item is living on a prayer." + elif self.condition == 3: + return f"Items condition is rated 3. This item is in working order." + elif self.condition == 4: + return f"Items condition is rated 4. This item is in good condition." + else: + return f"Items condition is rated 5. This item is in excellent condition." + #electronics = "Stereo" key="type" diff --git a/swap_meet/item.py b/swap_meet/item.py index 70faca413..b8096ac77 100644 --- a/swap_meet/item.py +++ b/swap_meet/item.py @@ -1,7 +1,8 @@ import uuid class Item: - def __init__(self, id=None): + def __init__(self, id=None, condition=0): + self.condition = condition #if id is not manually assigned if id == None: self.id = uuid.uuid4().int @@ -16,6 +17,16 @@ def get_category(self): def __str__(self): return f"An object of type {self.get_category()} with id {self.id}." - - def condition_description(self): - return f"{self.get_category()} heavily used. Condition rated 0." \ No newline at end of file +def condition_description(self): + if self.condition == 0: + return f"Item condition is rated 0. This item is barely holding on!" + elif self.condition == 1: + return f"Items condition is rated 1. This item is hanging on by a thread!" + elif self.condition == 2: + return f"Items condition is rated 2. This item is living on a prayer." + elif self.condition == 3: + return f"Items condition is rated 3. This item is in working order." + elif self.condition == 4: + return f"Items condition is rated 4. This item is in good condition." + else: + return f"Items condition is rated 5. This item is in excellent condition." From ed94b6f916f4fc1eee5480958e9ce5f0e0fa8f65 Mon Sep 17 00:00:00 2001 From: Niambi Date: Sun, 16 Apr 2023 22:13:07 -0700 Subject: [PATCH 11/11] Wrote mothods get_by_category, get_best_by_category, and swap_best_by_category to pass wave_06 tests. Wrote wave_06 test assertions to complete wave_06 tests. --- swap_meet/vendor.py | 46 +++++++++++------ tests/unit_tests/test_wave_06.py | 84 ++++++++++++++++++++------------ 2 files changed, 84 insertions(+), 46 deletions(-) diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index 74ce582b9..9495ed2b1 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -46,21 +46,39 @@ def swap_first_item(self, other_vendor): return False else: #look at the syntax here + other_vendor.add(self.inventory[0]) self.remove(self.inventory[0]) - other_vendor.remove(other_vendor.inventory[0]) - other_vendor.add(self.inventory[0]) self.add(other_vendor.inventory[0]) + other_vendor.remove(other_vendor.inventory[0]) return True - # ERROR: assert item_d in fatimah.inventory - #item_a = Item() - # item_b = Item() - # item_c = Item() - # fatimah = Vendor( - # inventory=[item_a, item_b, item_c] - # ) - # item_d = Item() - # item_e = Item() - # jolie = Vendor( - # inventory=[item_d, item_e] - # ) \ No newline at end of file + def get_by_category(self, category): + objects = [] + + for item in self.inventory: + if item.get_category() == category: + objects.append(item) + return objects + + def get_best_by_category(self, category): + + items = self.get_by_category(category) + if items == []: + return None + else: + highest_condition = items[0] + for item in items: + if item.condition >= highest_condition.condition: + highest_condition = item + return highest_condition + + def swap_best_by_category(self, other_vendor, my_priority, their_priority): + my_best_item = self.get_best_by_category(their_priority) + + their_best_item = other_vendor.get_best_by_category(my_priority) + + if my_best_item == None or their_best_item == None: + return False + else: + self.swap_items(other_vendor, my_best_item, their_best_item) + return True diff --git a/tests/unit_tests/test_wave_06.py b/tests/unit_tests/test_wave_06.py index ad51bf42d..97301fc7c 100644 --- a/tests/unit_tests/test_wave_06.py +++ b/tests/unit_tests/test_wave_06.py @@ -5,7 +5,7 @@ from swap_meet.decor import Decor from swap_meet.electronics import Electronics -@pytest.mark.skip +#@pytest.mark.skip def test_get_items_by_category(): item_a = Clothing() item_b = Electronics() @@ -22,7 +22,7 @@ def test_get_items_by_category(): assert item_a in items assert item_c in items -@pytest.mark.skip +#@pytest.mark.skip def test_get_no_matching_items_by_category(): item_a = Clothing() item_b = Item() @@ -33,12 +33,9 @@ def test_get_no_matching_items_by_category(): items = vendor.get_by_category("Electronics") - raise Exception("Complete this test according to comments below.") - # ********************************************************************* - # ****** Complete Assert Portion of this test ********** - # ********************************************************************* + assert len(items) == 0 -@pytest.mark.skip +#@pytest.mark.skip def test_best_by_category(): item_a = Clothing(condition=2.0) item_b = Decor(condition=2.0) @@ -54,7 +51,7 @@ def test_best_by_category(): assert best_item.get_category() == "Clothing" assert best_item.condition == pytest.approx(4.0) -@pytest.mark.skip +#@pytest.mark.skip def test_best_by_category_no_matches_is_none(): item_a = Decor(condition=2.0) item_b = Decor(condition=2.0) @@ -67,7 +64,7 @@ def test_best_by_category_no_matches_is_none(): assert best_item is None -@pytest.mark.skip +#@pytest.mark.skip def test_best_by_category_with_duplicates(): # Arrange item_a = Clothing(condition=2.0) @@ -84,7 +81,7 @@ def test_best_by_category_with_duplicates(): assert best_item.get_category() == "Clothing" assert best_item.condition == pytest.approx(4.0) -@pytest.mark.skip +#@pytest.mark.skip def test_swap_best_by_category(): # Arrange # me @@ -110,16 +107,23 @@ def test_swap_best_by_category(): their_priority="Decor" ) - raise Exception("Complete this test according to comments below.") - # ********************************************************************* - # ****** Complete Assert Portion of this test ********** - # ********************************************************************* + assert result == True + 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 jesse.inventory + assert item_d in jesse.inventory + assert item_e in jesse.inventory + assert item_f in tai.inventory + assert item_c not in tai.inventory + assert item_f not 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 +#@pytest.mark.skip def test_swap_best_by_category_reordered(): # Arrange item_a = Decor(condition=2.0) @@ -143,16 +147,22 @@ def test_swap_best_by_category_reordered(): their_priority="Decor" ) - raise Exception("Complete this test according to comments below.") - # ********************************************************************* - # ****** Complete Assert Portion of this test ********** - # ********************************************************************* + assert result == True + assert len(tai.inventory) == 3 + assert len(jesse.inventory) == 3 + assert item_a in tai.inventory + assert item_b in tai.inventory + assert item_f in tai.inventory + assert item_c in jesse.inventory + assert item_d in jesse.inventory + assert item_e 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 +#@pytest.mark.skip def test_swap_best_by_category_no_inventory_is_false(): tai = Vendor( inventory=[] @@ -178,7 +188,7 @@ 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 +#@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) @@ -204,7 +214,7 @@ 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 +#@pytest.mark.skip def test_swap_best_by_category_no_match_is_false(): # Arrange item_a = Decor(condition=2.0) @@ -228,16 +238,22 @@ def test_swap_best_by_category_no_match_is_false(): their_priority="Clothing" ) - raise Exception("Complete this test according to comments below.") - # ********************************************************************* - # ****** Complete Assert Portion of this test ********** - # ********************************************************************* + assert result == False + 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 +#@pytest.mark.skip def test_swap_best_by_category_no_other_match_is_false(): # Arrange item_a = Decor(condition=2.0) @@ -261,11 +277,15 @@ def test_swap_best_by_category_no_other_match_is_false(): their_priority="Decor" ) - raise Exception("Complete this test according to comments below.") - # ********************************************************************* - # ****** Complete Assert Portion of this test ********** - # ********************************************************************* - # Assertions should check: + assert result == False + 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 # - 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