Submission project_swap_meet by Sorida Lac C17#88
Submission project_swap_meet by Sorida Lac C17#88soridalac wants to merge 13 commits intoada-c17:masterfrom
Conversation
jericahuang
left a comment
There was a problem hiding this comment.
Fantastic work on this project, Sorida! The code you wrote passed all the tests and met the learning goals. You had wonderful code style and great comments throughout. Your project is green 🟢 ! Congrats on completing Unit 1!
| return "Hello World!" | ||
|
|
||
| def condition_description(self): | ||
| CONDITIONS = { |
There was a problem hiding this comment.
Lovely use of a constants dictionary to log the condition numbers to their descriptions!
| if not self.get_by_category(category): | ||
| return None | ||
| # Return the item that are match category and highest condition even there's duplicate items | ||
| return max(self.get_by_category(category), key=attrgetter("condition")) |
| their_best_item = other.get_best_by_category(my_priority) | ||
|
|
||
| # Return swap best items between Vendor and Vendor friend's from inventory | ||
| return self.swap_items(other, my_best_item, their_best_item) |
There was a problem hiding this comment.
Great use of .swap_items() as a helper function to DRY your code!
|
|
||
| def get_by_category(self, category): | ||
| # Return a list of item inventory from that category | ||
| return [item for item in self.inventory if item.category == category] |
| def swap_items(self, other, my_item, their_item): | ||
|
|
||
| # Check if Vendor items not in her inventory or Vendor friend's item not in their inventory | ||
| if not my_item in self.inventory or not their_item in other.inventory: |
|
|
||
| raise Exception("Complete this test according to comments below.") | ||
| #raise Exception("Complete this test according to comments below.") | ||
| assert item_a != items |
There was a problem hiding this comment.
Close! != is testing for non-equality. We'd want to check that the item_a, item_b, and item_c are not in items since none of their categories are "electronics".
|
|
||
| @pytest.mark.skip | ||
| assert tai.get_best_by_category("Decor").category == "Decor" | ||
| assert jesse.get_best_by_category("Clothing").category == "Clothing" |
| # - That all the correct items are in tai and jesse's inventories | ||
| assert item_a in tai.inventory | ||
| assert item_b in tai.inventory | ||
| assert item_c in tai.inventory |
| # - That all the correct items are in tai and jesse's inventories | ||
| assert item_a in tai.inventory | ||
| assert item_b in tai.inventory | ||
| assert item_c in tai.inventory |
| # - 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 | ||
| assert tai.get_best_by_category("Decor").category == "Decor" |
There was a problem hiding this comment.
Nice check! It would also be helpful to assert that the items that were swapped are not in their original inventories!
Thank you for taking time to review my codes and give feedbacks :)