Skip to content

Sea Turtles - Adriana & Olive - Solar System#26

Open
olive-lavine wants to merge 19 commits intoada-c17:mainfrom
adrianajg:main
Open

Sea Turtles - Adriana & Olive - Solar System#26
olive-lavine wants to merge 19 commits intoada-c17:mainfrom
adrianajg:main

Conversation

@olive-lavine
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.

Test

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.

Hey folks, I'm sorry my comments weren't published when I said they would be! Great work on part 1, I've left a few comments, please reach out if you have any questions on the feedback 🙂

Comment thread app/routes.py Outdated
Comment thread app/routes.py Outdated
Comment thread app/routes.py Outdated
Comment thread app/routes.py Outdated
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 looking code Adriana & Olive! I've left a few comments & questions, feel free to reply here or message me on Slack if you have questions on the feedback 🙂

Comment thread app/__init__.py
"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.

The line app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False is duplicated in both parts of the if/else. We could move that line to either above or below the if/else, so it only needs to be written once.

Comment thread app/models/planet.py
Comment on lines +10 to +16
planet_dict = dict(
id = self.id,
name = self.name,
description = self.description,
gravity = self.gravity
)
return planet_dict
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 is perfectly valid, but we could also return the dictionary without storing it in a variable like in from_dict below.

Comment thread app/routes/routes.py
Comment on lines +46 to +47
if not result_list:
return jsonify("No planets found with that name.")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hmm, what happens if you try to get all planets, but there are no planets stored in the db yet? It looks like result_list would be an empty list after line 44, so we'd enter the if-block on line 46 and print the error "No planets found with that name." even though it doesn't quite apply. How could we make sure that message is only returned when relevant?

Comment thread app/routes/routes.py
except KeyError as err:
error_message(f"Missing key: {err}", 400)

def replace_planet_safely(planet, data_dict):
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 helper functions ^_^

Comment thread app/routes/routes.py
return jsonify(f"Planet #{planet.id} successfully deleted.")

@planets_bp.route("/<id>", methods = ["PATCH"])
def update_planet_with_id(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.

Nice patch function!

Comment thread tests/test_routes.py
Comment on lines +66 to +67
assert response.status_code == 201
assert response_body == "Planet Mercury successfully created"
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 checks for both the status code and relevant response data across the 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.

3 participants