-
Notifications
You must be signed in to change notification settings - Fork 21
swap-meet AC2 - Catherine Bandarchuk #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…st_wave_2 passed.
…te swap_items method. Test_wave4
… Class. Test_wave5 passed.
… in Vendor class. Test_wave7 is passed.
…r class. Test_wave7 passed.
kelsey-steven-ada
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work Kate! I've left a mix of suggestions and questions to consider for feedback. Please reply here on Github or reach out on Slack if there's anything I can clarify =]
|
|
||
|
|
||
| def __str__( self ): | ||
| return f"An object of type {super().get_category()} with id {str(self.id)}. It is made from {str(self.fabric)} fabric." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The superclass __str__ function returns f"An object of type {self.get_category()} with id {str(self.id)}". We could use this reduce a little bit of repetition:
base_msg = super().__str__()
return f"{base_msg}. It is made from {str(self.fabric)} fabric." | class Decor( Item ): | ||
|
|
||
| def __init__( self, id = None, condition = None, width = None, length = None ): | ||
| super().__init__(id, condition) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm noticing that in some places there are spaces around keywords or arguments in parentheses. It isn't common to add spaces between parentheses and what goes inside them, to be consistent across the code, I recommend removing them in the future.
| if fabric == None: | ||
| self.fabric = "Unknown" | ||
| else: | ||
| self.fabric = fabric |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option here could be a python conditional assignment:
# Assigns self.fabric to the parameter fabric if it is truthy,
# otherwise assigns self.fabric the value "Unknown"
self.fabric = fabric if fabric else "Unknown"| super().__init__( id, condition ) | ||
|
|
||
| if fabric == None: | ||
| self.fabric = "Unknown" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strings are an immutable type; unlike lists and dictionaries, we could set the default in the function definition to "Unknown", which could let us remove the if-check.
|
|
||
| def __str__(self): | ||
|
|
||
| return f'''An object of type {super().get_category()} with id {str(self.id)}. It takes up a {str(self.width)} by {str(self.lenght)} sized space.''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would want to break this up over a couple lines to meet the best practice of keeping lines under 79 characters. One option could be to close the quotes and use a \ at the end of the line:
return f"An object of type {super().get_category()} with id {str(self.id)}. " \
f"It takes up a {str(self.width)} by {str(self.lenght)} sized space."| if not my_item or not their_item: | ||
| return False | ||
|
|
||
| else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could remove the else here and unindent return self.swap_items(other_vendor, my_item, their_item) without changing the result of the function.
| if self.swap_by_id( other_vendor, my_item_id, their_item_id ): | ||
| return True | ||
| return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could remove the if/else by directly returning the result of self.swap_by_id.
| assert item_c in tai.inventory | ||
|
|
||
| assert len(jesse.inventory) == 1 | ||
| assert item_e in jesse.inventory No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the tests you added!
| # ********************************************************************* | ||
| # ****** Complete Assert Portion of this test ********** | ||
| # ********************************************************************* | ||
| assert result == None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice assert, we definitely want to confirm our return value is None. We generally also want to confirm that there weren't side affects or changes to the input that we didn't intend. What could we check about the vendor's inventory to confirm that its content didn’t change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert len(vendor.inventory) == 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely! Since knowing the length doesn't guarantee the individual elements are still what we expect, we might also check the elements of the inventory list.
| # ********************************************************************* | ||
| assert result == False | ||
| assert len(jolie.inventory) == 0 | ||
| assert len(fatimah.inventory) == fatimah_len_l |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great assertions, I would also suggest checking the inventory contents, since the length being correct doesn't guarantee that the individual elements are still what we expect.
No description provided.