-
Notifications
You must be signed in to change notification settings - Fork 79
Tigers Part 1 - Paje and Lain #27
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Paje-Bishop <[email protected]>
Co-authored-by: Paje-Bishop <[email protected]>
Co-authored-by: Paje-Bishop <[email protected]>
Co-authored-by: allcomputersarebad <[email protected]>
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.
Nicely done Paje & Lain. I left some comments/suggestions, if you have questions ping me on Slack.
def planet_dict(self): | ||
return { | ||
"id": self.id, | ||
"name": self.name, | ||
"description": self.description, | ||
"mass": self.mass, | ||
} |
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.
Good helper function
planets_result = Planet.query.all() | ||
return jsonify([p.planet_dict() for p in planets_result]), 200 | ||
elif request.method == "POST": | ||
request_body = request.get_json() |
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.
Some validation to make sure the request_body
is valid (has required fields) would be good.
assert response.status_code == 400 | ||
|
||
|
||
def test_delete_planet(client, two_saved_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.
You should also test what happens when you delete a planet that doesn't exist.
assert response_body == {"success": "Planet #1 successfully deleted"} | ||
|
||
|
||
def test_update_planet(client, two_saved_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.
You should also test invalid updates like when the id doesn't exist or there is an invalid request body.
assert response_body == {"success": "Planet #1 successfully updated"} | ||
|
||
|
||
def test_name_query(client, two_saved_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.
Love this test ❤️
No description provided.