Skip to content

Ocelots - Xuan Hien Pham#6

Open
HienXuanPham wants to merge 10 commits intoada-ac2:mainfrom
HienXuanPham:main
Open

Ocelots - Xuan Hien Pham#6
HienXuanPham wants to merge 10 commits intoada-ac2:mainfrom
HienXuanPham:main

Conversation

@HienXuanPham
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@kelsey-steven-ada kelsey-steven-ada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work Chelsea! 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 =]

Comment thread swap_meet/clothing.py
class Clothing(Item):
def __init__(self, id=None, condition=None, fabric=None):
super().__init__(id, condition)
self.fabric = "Unknown" if fabric is None else fabric
Copy link
Copy Markdown

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.

Comment thread swap_meet/clothing.py
Comment on lines +8 to +9
def get_category(self):
return super().get_category()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function passes along the superclass response, we could actually remove the function definition from the child class completely and python would call the superclass method by default. The same feedback applies to condition_description below.

Comment thread swap_meet/item.py
Comment on lines +8 to +9
def __str__(self):
return f"An object of type Item with id {str(self.id)}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hardcoding the class name, we could make a dynamic call to get_category:

return f"An object of type {self.get_category()} with id {str(self.id)}"

This would let us reduce some repetition in the child classes since they could call the superclass __str__ to get the first sentence of the child class string descriptions.

Comment thread swap_meet/item.py
Comment on lines +5 to +6
self.id = uuid.uuid4().int if id is None else id
self.condition = 0 if condition is None else condition
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice conditional assignments!

Comment thread swap_meet/item.py
return self.__class__.__name__

def condition_description(self):
if 0 <= self.condition <= 1:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the use of ranges to account for decimal condition values.

Comment thread swap_meet/vendor.py
Comment on lines +84 to +88
my_id = int(input("Enter my id: "))
their_id = int(input("Enter their id: "))

result = self.swap_by_id(other_vendor, my_id, their_id)
return result
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you've implemented the swapping, as part of this function, we also want to print the inventory so a user can see what items are available and then choose which item they want. What code would you add to support that?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.display_inventory(category)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@pytest.mark.skip
@pytest.mark.integration_test
#@pytest.mark.skip
#@pytest.mark.integration_test
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For integration tests, we want to leave the decorator @pytest.mark.integration_test uncommented. This decorator tells pytest that this is an integration test, so we should run it after all of the unit tests.

Comment on lines +52 to +53
assert len(vendor.inventory) == 3
assert result is None
Copy link
Copy Markdown

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.

Comment on lines +134 to +136
assert not result
assert len(fatimah.inventory) == 3
assert len(jolie.inventory) == 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feedback in wave 1 applies here as well, what else would be helpful to assert to ensure there were no unintended side effects?

assert item_b in tai.inventory
assert item_c in tai.inventory

assert len(jesse.inventory) == 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the added tests!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants