Open
Conversation
…created blueprint endpoint get_planets
…ed class instance method to_json
…OST /planets, GET /planets
spitsfire
reviewed
May 2, 2022
spitsfire
left a comment
There was a problem hiding this comment.
Part 1! Nicely done! Left a few suggestions here and there, but your logic looks good
| description = db.Column(db.String) | ||
| order_in_ss = db.Column(db.String) | ||
|
|
||
| def to_json(self): |
app/routes.py
Outdated
|
|
||
|
|
||
|
|
||
| planets_bp = Blueprint("planets", __name__, url_prefix = "/planets") |
There was a problem hiding this comment.
we only need this assigned once at the top!
Suggested change
| planets_bp = Blueprint("planets", __name__, url_prefix = "/planets") |
app/routes.py
Outdated
Comment on lines
27
to
28
| for planet in planets: | ||
| planets_response.append(planet.to_json()) |
There was a problem hiding this comment.
we could also do this with list comprehension:
Suggested change
| for planet in planets: | |
| planets_response.append(planet.to_json()) | |
| planets_response = [planet.to_json() for planet in planets] |
app/routes.py
Outdated
| for planet in planets: | ||
| planets_response.append(planet.to_json()) | ||
|
|
||
| return jsonify(planets_response) |
There was a problem hiding this comment.
don't forget your status codes!
Suggested change
| return jsonify(planets_response) | |
| return jsonify(planets_response), 200 |
…nce method update and class method create.
…T endpoint method
…iles, populated testconfit, created fixtures, create test get_planet for empty db
…data, and create one planet
spitsfire
reviewed
May 9, 2022
spitsfire
left a comment
There was a problem hiding this comment.
Nicey done, Ivana and Lauren! I didn't find any red flags or any logic issues! Looks good!
| "order in solar system": self.order_in_ss | ||
| } | ||
|
|
||
| def update_planet(self, update_body): |
| self.order_in_ss = update_body["order in solar system"] | ||
|
|
||
| @classmethod | ||
| def create_planet(cls, request_body): |
| @@ -0,0 +1,14 @@ | |||
| from flask import abort, make_response | |||
| new_planet = cls( | ||
| name=request_body['name'], | ||
| description=request_body['description'], | ||
| order_in_ss=request_body['order in solar system'], |
There was a problem hiding this comment.
careful with spaces! while this works syntactically, I don't think it's very common to see keys with spaces like this. Maybe something like order_in_ss might look better
| @@ -0,0 +1,55 @@ | |||
| from app import db | |||
| @@ -0,0 +1,41 @@ | |||
| import pytest | |||
| @@ -0,0 +1,64 @@ | |||
| def test_get_all_planets_with_no_records(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.