Skip to content

C22-Phoenix-Amber Edwards & Sphinx- Weixi He#2

Open
Msambere wants to merge 12 commits intoAda-C22:mainfrom
Msambere:main
Open

C22-Phoenix-Amber Edwards & Sphinx- Weixi He#2
Msambere wants to merge 12 commits intoAda-C22:mainfrom
Msambere:main

Conversation

@Msambere
Copy link

@Msambere Msambere commented Oct 2, 2024

No description provided.

Copy link
Collaborator

@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! 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 on lines +2 to +3
# Testing github connection weixi
# Testing github connections
Copy link
Collaborator

Choose a reason for hiding this comment

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

After testing the connection, we should remove changes like this that we don't want to bring into our final product.

return "Item"

def __str__(self):
return f"An object of type Item with id {self.id}."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Every child class starts with a sentence of this exact form. A child class can call their parent's functions using super.

If instead of hardcoding the category Item in this string we called self.get_category(), how could we share this function with the child classes to reduce similar or repeated code in their __str__ functions?

def condition_description(self):
descript_dict ={
0: "Just burn it",
1: "Maybe re-gift to someone you don't like.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

😂

5: "Pristine!"
}

return descript_dict[self.condition]
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't test for this, and it isn't a requirement, but something to consider:

  • In the Wave 5 description the condition can be 0-5, so what happens if the condition is a decimal rather than an integer?
  • How could we update the function to handle both types?

class Vendor:
pass No newline at end of file
def __init__(self, inventory=None):
self.inventory = [] if inventory is None else inventory
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great use of a python ternary statement!

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

Choose a reason for hiding this comment

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

This marker should not be commented out in the integration test files. For more info, check the README section for the project on Integration Tests.

Comment on lines +52 to +54
assert len(vendor.inventory) == 3
assert result is False
assert vendor.inventory == ["a", "b", "c"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great assertions to check the return value is as-expected and that no items in the inventory were unexpectedly changed!

item_c = Item()
fatimah = Vendor(
inventory=[item_a, item_b, item_c]
inventory=["a", "b", "c"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

The existing data in the "Arrange" step should not be changed when adding assertions for these tests.

  • What could the assertions look like using the original data for this test?

raise Exception("Complete this test according to comments below.")
# Assert
assert result
assert len(tai.inventory) == 3 and len(jesse.inventory) == 3
Copy link
Collaborator

Choose a reason for hiding this comment

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

When writing tests, we want to write individual assert statements for each condition we are checking. When we write multiple checks on a single line, then we need to do further investigation to figure out which expression is failing if the test fails.

Comment on lines +113 to +114
assert item_a in tai.inventory and item_b in tai.inventory and item_f in tai.inventory
assert item_d in jesse.inventory and item_e in jesse.inventory and item_c in jesse.inventory
Copy link
Collaborator

Choose a reason for hiding this comment

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

These lines are a bit long. If we want to condense the checks for all items to a single line, one approach would be to convert the lists to sets and use set operations:

assert {item_f, item_a, item_b}.issubset(tai.inventory)
assert {item_c, item_d, item_e}.issubset(jesse.inventory)

We could also use all:

assert all(item in tai.inventory for item in [item_f, item_a, item_b])
assert all(item in jesse.inventory for item in [item_c, item_d, item_e])

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