-
Notifications
You must be signed in to change notification settings - Fork 128
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
Task List API - Jasmine S. #134
base: main
Are you sure you want to change the base?
Conversation
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.
Excellent job! There are some minor comments below. Great job!
from .routes.task_routes import task_bp | ||
app.register_blueprint(task_bp) | ||
from .routes.goal_routes import goal_bp | ||
app.register_blueprint(goal_bp) | ||
from .routes.goal_task_routes import goal_task_bp | ||
app.register_blueprint(goal_task_bp) |
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.
Excellent!
@@ -3,3 +3,12 @@ | |||
|
|||
class Goal(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.
Excellent!
title = db.Column(db.String) | ||
tasks = db.relationship("Task", back_populates="goal", lazy=True) | ||
|
||
def to_dict(self): |
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.
Yay, helper function!
@@ -2,4 +2,28 @@ | |||
|
|||
|
|||
class Task(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.
Excellent!
def to_dict(self): | ||
task = { | ||
"id": self.task_id, | ||
"title": self.title, | ||
"description": self.description, | ||
"is_complete": False, | ||
} | ||
if self.completed_at is not None: | ||
task["is_complete"] = True | ||
if self.goal_id is not None: | ||
task["goal_id"] = self.goal_id | ||
return task | ||
|
||
@classmethod | ||
def from_dict(cls, task_data): | ||
new_task = Task(title=task_data["title"], | ||
description=task_data["description"]) | ||
return new_task |
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.
Yay, helper functions!
response = client.put("/goals/1", json={ | ||
"title": "Updated Goal Title" | ||
}) | ||
response_body = response.get_json() | ||
|
||
# Assert | ||
# ---- Complete Assertions Here ---- | ||
# assertion 1 goes here | ||
# assertion 2 goes here | ||
# assertion 3 goes here | ||
# ---- Complete Assertions Here ---- | ||
assert response.status_code == 200 | ||
assert "goal" in response_body | ||
assert response_body == { | ||
"goal": { | ||
"id": 1, | ||
"title": "Updated Goal Title", | ||
} | ||
} | ||
goal = Goal.query.get(1) | ||
assert goal.title == "Updated Goal Title" |
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.
Excellent!
response = client.put("/goals/1", json={ | ||
"title": "Updated Goal Title" | ||
}) | ||
response_body = response.get_json() | ||
|
||
# Assert | ||
# ---- Complete Assertions Here ---- | ||
# assertion 1 goes here | ||
# assertion 2 goes here | ||
# ---- Complete Assertions Here ---- | ||
assert response.status_code == 404 | ||
assert response_body is None |
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.
Excellent!
response_body = response.get_json() | ||
assert response.status_code == 404 | ||
assert not response_body |
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.
Excellent!
response = client.delete("/goals/1") | ||
response_body = response.get_json() | ||
|
||
# Assert | ||
# ---- Complete Assertions Here ---- | ||
# assertion 1 goes here | ||
# assertion 2 goes here | ||
# ---- Complete Assertions Here ---- | ||
assert response.status_code == 404 | ||
assert response_body is None | ||
assert Goal.query.all() == [] |
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.
Excellent!
def test_get_tasks_for_specific_goal_no_goal(client): | ||
# Act | ||
response = client.get("/goals/1/tasks") | ||
response_body = response.get_json() | ||
|
||
# Assert | ||
assert response.status_code == 404 | ||
assert not response_body |
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.
Excellent!
No description provided.