Ada c17 whales-Nishat Salsabil#96
Conversation
…ve. All unit tests in Wave 01 passing; Wave 01 complete.
…and Waves 01-02 complete
… 03 test cases complete
… in wave 05 passing; wave 05 complete
… passing; waves 01-06 complete
…e class Item's super function in subclasses; all waves and integration tests passing
… added 2 instance methods: get_newest_item and swap_by_newest to Vendor Class, added an attribute age to Item Class
…in Wave 05, waves 01-07 and integration tests passing
jericahuang
left a comment
There was a problem hiding this comment.
Fantastic work on this project, Nish! The code you wrote passed all the tests and met the learning goals. Phenomenal job on the optional enhancements and completing the tests. Your project is green 🟢 ! Congratulations on completing Unit 1!
| class Item: | ||
| pass No newline at end of file | ||
| def __init__(self, category = None, condition = 0, age = 0): | ||
| if not category: |
There was a problem hiding this comment.
If we don't specify a category, it will be None because of category = None in the constructor!
| return "Hello World!" | ||
|
|
||
|
|
||
| def age_statement(self): |
There was a problem hiding this comment.
Nice addition of an age statement!
| their_item = other_vendor.inventory[0] | ||
| first_items = self.swap_items(other_vendor, my_item, their_item) | ||
| return first_items | ||
| except IndexError: |
There was a problem hiding this comment.
Wonderful try-except and catching IndexError!
| if item in self.inventory: | ||
| self.inventory.remove(item) | ||
| return item | ||
| return False |
There was a problem hiding this comment.
Nice use of short-circuiting and returning False at the end!
| 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) |
There was a problem hiding this comment.
Great use of helper functions to DRY your code!
|
|
||
| assert newest_item | ||
| assert newest_item.category == "Clothing" | ||
| assert newest_item.age == pytest.approx(1) |
|
|
||
| newest_item = nishat.get_newest_item() | ||
|
|
||
| assert newest_item is None |
| 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 |
|
|
||
| # Test 40 | ||
| #@pytest.mark.skip | ||
| def test_swap_newest_item_reordered(): |
There was a problem hiding this comment.
Awesome test idea for another ordering!
| their_item = nishat.get_newest_item() | ||
| ) | ||
|
|
||
| assert not result |
An additional wave 07 was created for the optional enhancement section of the project.