Conversation
…messages if endpoint is invalid.
…pdate your own database with upgrade commands
…ed. HTTP GET request returns all entries in database.
…fetching all planets and return [] passes.
CheezItMan
left a comment
There was a problem hiding this comment.
Overall nice work. I left some suggestions for future APIs. Also try to remember to include venv in your .gitignore file so it doesn't get included in the Pull Request.
| id = db.Column(db.Integer, primary_key=True, autoincrement=True) | ||
| name = db.Column(db.String) | ||
| description = db.Column(db.String) | ||
|
|
There was a problem hiding this comment.
some helper methods like
def to_dict(self):
return {
"name": self.name,
"color": self.color,
"description": self.description,
"id": self.id
}
@classmethod
def from_json(cls, input_dict):
return cls(
name= input_dict["name"],
color= input_dict["color"],
description= input_dict["description"]
)Might be helpful
| planets_bp = Blueprint('planets_bp', __name__, url_prefix='/planets') | ||
|
|
||
| @planets_bp.route("", methods=["POST"]) | ||
| def create_planet(): |
There was a problem hiding this comment.
Some input validation on the request body would be appropriate here.
| planets_response.append({ | ||
| "id": planet.id, | ||
| "name": planet.name, | ||
| "description": planet.description | ||
| }) |
There was a problem hiding this comment.
This would be a great place to use that helper method I listed in the Planet Class.
|
|
||
|
|
||
| @planets_bp.route("/<planet_id>", methods=["GET"]) | ||
| def handle_planet(planet_id): |
There was a problem hiding this comment.
Why name this handle_planet instead of get_planet?
| assert len(response_body) == 1 | ||
|
|
||
|
|
||
| def test_create_planet(client): |
There was a problem hiding this comment.
You should also test the create action with an invalid input.
| assert response_body == "Planet Earth has been added to the Planets database." | ||
|
|
||
|
|
||
| def test_update_planet_entry(client, one_planet_in_database): |
There was a problem hiding this comment.
You should also have a test for the update action with invalid input
| assert response_body == "Planet Earth has been updated in the Planets database." | ||
|
|
||
|
|
||
| def test_delete_planet_entry(client, one_planet_in_database): |
There was a problem hiding this comment.
You should also try to test delete actions with invalid planet ids. Basically testing the 404 response.
No description provided.