Skip to content

Kunzite - Barbara B. and Erina P.#14

Open
erinaperez wants to merge 14 commits intoAda-C19:mainfrom
erinaperez:main
Open

Kunzite - Barbara B. and Erina P.#14
erinaperez wants to merge 14 commits intoAda-C19:mainfrom
erinaperez:main

Conversation

@erinaperez
Copy link
Copy Markdown

Waves 01 and 02

Copy link
Copy Markdown

@marciaga marciaga left a comment

Choose a reason for hiding this comment

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

Good work on Waves 01-02! I just left one comment below.

Comment thread app/routes.py Outdated
def handle_planet(planet_id):
planet = validate_planet(planet_id)

return {
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'd recommend creating a make_dict instance method on the Planet class similar to how we did it in Flasky. That way you won't have to manually create dictionaries every time you want to return a Planet instance.

Copy link
Copy Markdown

@marciaga marciaga left a comment

Choose a reason for hiding this comment

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

Nice work! Way to add additional testing as well!

Comment thread app/__init__.py Outdated
"SQLALCHEMY_DATABASE_URI")
else:
app.config["TESTING"] = True
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this line of code appears in both the if and else blocks so it could be extracted and moved outside this control flow, so the line doesn't get repeated.

Comment thread app/routes.py
bp = Blueprint("planets", __name__, url_prefix="/planets")

# VALIDATE PLANET HELPER FUNCTIONS
def validate_model(cls, model_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.

Even though there's only one model in this codebase, this function is generic and could be used with any model, so it would be ideal to move it into its own helpers file.

Comment thread app/routes.py
def read_all_planets():
name_query = request.args.get("name")

if name_query:
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 job adding the ability to pass the name query string parameter!

Comment thread tests/test_models.py

def test_to_dict_no_missing_data():
# Arrange
test_data = Planet(id = 2,
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 spicy must flow

Comment thread tests/test_routes.py
assert response_body == []

# TEST ONE PLANET
def test_get_one_planet(client, two_saved_planets):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If you added a single saved planet fixture, you could use that to obtain the id instead of hard-coding it like below

Comment thread tests/test_models.py
# Assert
assert new_planet.name == "New planet"
assert new_planet.description == "The mild planet"
assert new_planet.position == "#40" No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thorough model tests! I think for this last one, if you want to make sure it doesn't contain any additional key/values, you should assert that the new_planet dictionary is identical with the key/values you have on separate lines, since new_planet might contain key/values you just aren't asserting for. If you use a dictionary, then it wouldn't be possible that additional key/values snuck in.

Comment thread tests/test_routes.py
assert response_body == "Planet Pink Star successfully created"


def test_get_all_planets_with_three_records(client, two_saved_planets):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Somewhat confused by the name of this test, since you're testing for two records!

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.

3 participants