Skip to content

Alexis Miller - Cheetahs #87

Open
LexElena22 wants to merge 6 commits intoAda-C18:masterfrom
LexElena22:master
Open

Alexis Miller - Cheetahs #87
LexElena22 wants to merge 6 commits intoAda-C18:masterfrom
LexElena22:master

Conversation

@LexElena22
Copy link

No description provided.

Copy link

@jbieniosek jbieniosek left a comment

Choose a reason for hiding this comment

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

Fantastic work on this project Lex! Really great use of helper methods throughout vendor. The code is very clean and easy to read. My only critical feedback is on the tests, I think being a bit more thorough and clear in what is being tested will take them to the next level. This project is green.

Comment on lines +4 to +5
def __init__(self, condition=0):
super().__init__("Clothing", condition)

Choose a reason for hiding this comment

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

👍

Comment on lines +5 to +7
if inventory is None:
inventory = []
self.inventory = inventory

Choose a reason for hiding this comment

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

💯

Comment on lines +22 to +24
for item in self.inventory:
if item.category == category:
items.append(item)

Choose a reason for hiding this comment

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

Nice!

Comment on lines +30 to +33
self.remove(my_item)
friend_vendor.add(my_item)
friend_vendor.remove(their_item)
self.add(their_item)

Choose a reason for hiding this comment

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

Great use of helper methods!

return False
my_first_item = self.inventory[0]
their_first_item = friend_vendor.inventory[0]
is_swapped = self.swap_items(friend_vendor, my_first_item, their_first_item)

Choose a reason for hiding this comment

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

🎉

if item.condition > top_condition:
top_condition = item.condition
return_item = item
return return_item

Choose a reason for hiding this comment

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

Great solution!

Comment on lines +56 to +58
my_best = self.get_best_by_category(their_priority)
their_best = other.get_best_by_category(my_priority)
return self.swap_items(other, my_best, their_best)

Choose a reason for hiding this comment

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

😍


raise Exception("Complete this test according to comments below.")
#added assert
assert result == False

Choose a reason for hiding this comment

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

I suggest adding a check to verify that the inventory wasn't changed by the remove action:

Suggested change
assert result == False
assert result == False
assert len(vendor.inventory) == 3

Comment on lines +79 to +86
assert len(tai.inventory) == len(jesse.inventory) == 3
assert len(tai.get_by_category("Clothing")) == 1
assert len(jesse.get_by_category("Clothing")) == 1
assert len(tai.get_by_category("Decor")) == 1
assert len(jesse.get_by_category("Decor")) == 2
assert tai.get_by_category("Decor")[0].condition == 2.0
assert tai.get_by_category("Clothing")[0].condition == 4.0
assert jesse.get_by_category("Clothing")[0].condition == 2.0

Choose a reason for hiding this comment

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

I recommend restructuring these tests to make sure the correct elements are swapped. It will make the asserts themselves a little simpler, but also check the specific action in the act step. Also, removing get_by_category reduces the possibility that a bug in that function will falsely register a bug here.

Suggested change
assert len(tai.inventory) == len(jesse.inventory) == 3
assert len(tai.get_by_category("Clothing")) == 1
assert len(jesse.get_by_category("Clothing")) == 1
assert len(tai.get_by_category("Decor")) == 1
assert len(jesse.get_by_category("Decor")) == 2
assert tai.get_by_category("Decor")[0].condition == 2.0
assert tai.get_by_category("Clothing")[0].condition == 4.0
assert jesse.get_by_category("Clothing")[0].condition == 2.0
assert item_a in tai.inventory
assert item_b in tai.inventory
assert item_f in tai.inventory
assert item_d in jesse.inventory
assert item_e in jesse.inventory
assert item_c in jesse.inventory

Comment on lines +124 to +126
assert item_f in tai.inventory
assert item_c in jesse.inventory
assert item_c not in tai.inventory

Choose a reason for hiding this comment

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

I recommend checking all of the items here, rather than just the ones that were swapped.

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