Skip to content
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 - Nina G. #117

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Sea Turtles - Nina G. #117

wants to merge 9 commits into from

Conversation

anacapamu
Copy link

No description provided.

Copy link

@tgoslee tgoslee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@@ -30,5 +28,10 @@ def create_app(test_config=None):
migrate.init_app(app, db)

# Register Blueprints here
from .task_routes import task_bp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea to create two seperate files for goals and tasks

"is_complete": bool(self.completed_at)
}

if self.goal_id:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

try:
new_goal = Goal(title=request_body["title"])
except KeyError:
error_message(f"Invalid data", 400)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great informative message here!

from .models.goal import Goal
import requests, os

def error_message(message, status_code):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants