Sea Turtles - Adriana & Olive - Solar System#26
Sea Turtles - Adriana & Olive - Solar System#26olive-lavine wants to merge 19 commits intoada-c17:mainfrom
Conversation
kelsey-steven-ada
left a comment
There was a problem hiding this comment.
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 🙂
kelsey-steven-ada
left a comment
There was a problem hiding this comment.
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 🙂
| "SQLALCHEMY_DATABASE_URI") | ||
| else: | ||
| app.config["TESTING"] = True | ||
| app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False |
There was a problem hiding this comment.
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.
| planet_dict = dict( | ||
| id = self.id, | ||
| name = self.name, | ||
| description = self.description, | ||
| gravity = self.gravity | ||
| ) | ||
| return planet_dict |
There was a problem hiding this comment.
This is perfectly valid, but we could also return the dictionary without storing it in a variable like in from_dict below.
| if not result_list: | ||
| return jsonify("No planets found with that name.") |
There was a problem hiding this comment.
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?
| except KeyError as err: | ||
| error_message(f"Missing key: {err}", 400) | ||
|
|
||
| def replace_planet_safely(planet, data_dict): |
There was a problem hiding this comment.
Love the helper functions ^_^
| return jsonify(f"Planet #{planet.id} successfully deleted.") | ||
|
|
||
| @planets_bp.route("/<id>", methods = ["PATCH"]) | ||
| def update_planet_with_id(id): |
| assert response.status_code == 201 | ||
| assert response_body == "Planet Mercury successfully created" |
There was a problem hiding this comment.
Nice checks for both the status code and relevant response data across the tests!
No description provided.