Skip to content
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

Ada S19 - Anh Huynh #77

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Ada S19 - Anh Huynh #77

wants to merge 8 commits into from

Conversation

hawktalk25
Copy link

No description provided.

Copy link

@mmcknett-ada mmcknett-ada left a comment

Choose a reason for hiding this comment

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

Green 🟢!

@pytest.mark.skip
@pytest.mark.integration_test
#@pytest.mark.skip
#@pytest.mark.integration_test

Choose a reason for hiding this comment

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

No need to remove the integration_test mark

@@ -143,7 +157,19 @@ def test_swap_best_by_category_reordered():
their_priority="Decor"
)

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

Choose a reason for hiding this comment

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

You could do assert result is True to make sure that an actual True comes out of the function instead of just a truthy value

Comment on lines +164 to +171
assert item_c not in tai.inventory
assert item_b in tai.inventory
assert item_a in tai.inventory
assert item_f in tai.inventory
assert item_f not in jesse.inventory
assert item_e in jesse.inventory
assert item_d in jesse.inventory
assert item_c in jesse.inventory

Choose a reason for hiding this comment

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

I appreciate that these are written out in detail!

class Clothing(Item):
# Define attributes for Clothing instances
def __init__(self, id = None, fabric = None, condition = None):

Choose a reason for hiding this comment

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

You could use the string literal default for fabric, since strings don't have the same problem that [] has.

Suggested change
def __init__(self, id = None, fabric = None, condition = None):
def __init__(self, id = None, fabric = "Unknown", condition = None):

class Decor(Item):
# Define attributes for Decor instances
def __init__(self, id = None, width = None, length = None, condition = None):

Choose a reason for hiding this comment

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

Integer defaults are fine, too!

Suggested change
def __init__(self, id = None, width = None, length = None, condition = None):
def __init__(self, id = None, width = 0, length = 0, condition = None):

# If attribute id in an instance has same value as attribute id in Item instance
# Return this instance. Otherwise, return None
if item.id == test_item.id:

Choose a reason for hiding this comment

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

I'd recommend not creating the fake Item with id. You could just make this:

Suggested change
if item.id == test_item.id:
if item.id == id:

# Remove friend's Item instance and add it to user's inventory
# Return True
else:

Choose a reason for hiding this comment

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

The else: isn't strictly necessary here because the return False above will exclude anything outside the if statement.

Comment on lines +64 to +67
# other_vendor.inventory.remove(friend_first_item)
# other_vendor.inventory.append(user_first_item)
# self.inventory.append(friend_first_item)

Choose a reason for hiding this comment

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

You can remove old code. If you commit before changing it, too, git will remember it for you.

Comment on lines +73 to +81
# Loop through each Item instance in inventory
for item in self.inventory:
# If an instance's category (aka class name) same as provided category,
# add this instance to resulting_list
if item.get_category() == category:
resulting_list.append(item)
# Return updated resulting_list
return resulting_list

Choose a reason for hiding this comment

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

Notice this pattern of:

result_list = []
for element in source_list:
    if some_condition(element):
        result_list.append(element)

can be rewritten using a list comprehension as:

result_list = [element for element in source_list if some_condition(element)]

Which here would look like:

resulting_list = [item for item in self.inventory if item.get_category() == category]
return resulting_list

At first, this may seem more difficult to read, but comprehensions are a very common python style, so I encourage y’all to try working with them!

Comment on lines +110 to +117
return False
else:
# Otherwise, call on swap_items method to swap user's and friend's
# matching best instances with each other
self.swap_items(other_vendor, user_best_match, other_best_match)
# return True
return True

Choose a reason for hiding this comment

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

Since swap_items can handle items that are None, you could also defer to it:

        return self.swap_items(other_vendor, user_best_match, other_best_match)

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