-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sea Turtles Heather M & Jenny C #19
base: main
Are you sure you want to change the base?
Conversation
app/routes.py
Outdated
description = planet.description, | ||
gravity = planet.gravity | ||
)) | ||
return jsonify(planets_result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here its nice to add a 200 status code. Even though it happens by default it adds readability to your code.
return jsonify(planets_result), 200
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good idea. We'll add this.Thank you Trenisha
app/routes.py
Outdated
|
||
|
||
class Planet: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks good!
app/routes.py
Outdated
planets_result.append(dict( | ||
id = planet.id, | ||
name = planet.name, | ||
description = planet.description, | ||
gravity = planet.gravity | ||
)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be moved to your planets class as an instance method. Then you would call that instance method here.
def make_dict(self):
return dict(
id=self.id,
name=self.name,
description=self.description,
gravity=self.gravity,
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. We should refactor it like that. Thank you for the suggestion.
app/routes.py
Outdated
planets_bp = Blueprint("planets", __name__, url_prefix="/planets") | ||
|
||
@planets_bp.route("", methods=["GET"]) | ||
def handle_planets(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conventionally you would see the naming of the function be similar to the CRUD operation you are performing. Like get_planets
or get_all_planets
…DO: complete wave 4 delete, test single planet get.
…lanets, implement description field search
|
||
return app | ||
else: | ||
print("Testing is on") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this for testing your code? Or was this intentional so that you know if you are testing?
from app import db | ||
|
||
|
||
class Planet(db.Model): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌🏽
@planets_bp.route("/teapot", methods=["GET", "POST"]) | ||
def handle_teapot(): | ||
return make_response("I'm a teapot!", 418) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this also yall testing some stuff out?
return { | ||
"id": planet.id, | ||
"order_from_sun": planet.order_from_sun, | ||
"name": planet.name, | ||
"description": planet.description, | ||
"gravity": planet.gravity | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in your Planet
class you can create an instance method to return this information. Then you can use the instance method over and over again.
name_query = request.args.get("name") | ||
description_query = request.args.get("description") | ||
order_from_sun_query = request.args.get("order_from_sun") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how you all added different ways to query for the planets
planets_response.append({ | ||
"id": planet.id, | ||
"order_from_sun": planet.order_from_sun, | ||
"name": planet.name, | ||
"description": planet.description, | ||
"gravity": planet.gravity | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could also be made an instance method in your Planet
class.
|
||
|
||
@pytest.fixture | ||
def app(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌🏽
@@ -0,0 +1,71 @@ | |||
# from hello-books | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests look good!
No description provided.