Conversation
tgoslee
left a comment
There was a problem hiding this comment.
Overall great job Nina! Your code was concise and well-organized. I left a few comments on things you did well and a few suggestions. Let me know if you have questions.
| migrate.init_app(app, db) | ||
|
|
||
| # Register Blueprints here | ||
| from .task_routes import task_bp |
There was a problem hiding this comment.
good idea to create two seperate files for goals and tasks
| "is_complete": bool(self.completed_at) | ||
| } | ||
|
|
||
| if self.goal_id: |
There was a problem hiding this comment.
great way to handle the optional attribute
| title = db.Column(db.String, nullable=False) | ||
| tasks = db.relationship("Task", back_populates="goal") | ||
|
|
||
| def to_dict(self): |
| try: | ||
| new_goal = Goal(title=request_body["title"]) | ||
| except KeyError: | ||
| error_message(f"Invalid data", 400) |
There was a problem hiding this comment.
I would suggest adding explicit messaging for the user to help them understand what's missing in their request
error_message("Invalid data: title is missing", 400)| db.session.delete(goal) | ||
| db.session.commit() | ||
|
|
||
| return make_response(jsonify(dict(details=f'Goal {goal.goal_id} "{goal.title}" successfully deleted'))), 200 |
| from .models.goal import Goal | ||
| import requests, os | ||
|
|
||
| def error_message(message, status_code): |
There was a problem hiding this comment.
The helper functions look good! I also like that you put them in a separate file.
| new_task = Task(title=request_body["title"], | ||
| description=request_body["description"]) | ||
| except KeyError: | ||
| error_message(f"Invalid data", 400) |
There was a problem hiding this comment.
Same suggestion as above about adding a more descriptive message for the user.
| # ***************************************************************** | ||
| # **Complete test with assertion about response body*************** | ||
| # ***************************************************************** | ||
| assert response_body == {"details": "task 1 not found"} |
There was a problem hiding this comment.
to make sure we are checking all of the data you can confirm that the database has no records, or that there is no record in the database with the ID of 1
No description provided.