Open
Conversation
jbieniosek
reviewed
Oct 21, 2021
jbieniosek
left a comment
There was a problem hiding this comment.
Great work on this project! This project is green.
|
|
||
| @planets_bp.route("", methods=["GET"]) | ||
| def get_all_planets(): | ||
| planets_response = [vars(planet) for planet in planets] |
| planet_id = int(planet_id) | ||
| for planet in planets: | ||
| if planet.id == planet_id: | ||
| return vars(planet) No newline at end of file |
There was a problem hiding this comment.
I recommend adding ‘jsonify’ to the return even in the case where the Flask default behavior is doing the same thing. Using ‘jsonify’ adds a layer of error protection and also makes it clear that json is the intended behavior.
Suggested change
| return vars(planet) | |
| return jsonify(vars(planet)) |
…a python dictionary
…ot input in a post request.
CheezItMan
reviewed
Oct 29, 2021
CheezItMan
left a comment
There was a problem hiding this comment.
Nice work Mac & Melinda, you hit the learning goals here. Well done!
| if not test_config: | ||
| app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False | ||
| app.config['SQLALCHEMY_DATABASE_URI'] = \ | ||
| 'postgresql+psycopg2://postgres:postgres@localhost:5432/solar_system_development' |
There was a problem hiding this comment.
Just a note: In future projects we can use an environmental variable rather than hard-coding the connection string here, like you do below with os.environ.get( "SQLALCHEMY_TEST_DATABASE_URI")
| description = db.Column(db.String) | ||
| moons = db.Column(db.String) | ||
|
|
||
| def to_dict(self): |
| Deletes specified planet entry and return success message for DELETE request.""" | ||
|
|
||
| planet_id = int(planet_id) | ||
| planet = Planet.query.get_or_404(planet_id) |
| @@ -0,0 +1,6 @@ | |||
| def test_handle_planets_returns_200_and_empty_array(client): | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.