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

Task List API - Jasmine S. #134

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open

Task List API - Jasmine S. #134

wants to merge 32 commits into from

Conversation

bunnaery
Copy link

No description provided.

bunnaery added 30 commits May 3, 2023 14:27
Copy link

@nancy-harris nancy-harris left a 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!

Comment on lines +34 to +39
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)

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

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

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

Choose a reason for hiding this comment

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

Excellent!

Comment on lines +12 to +29
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

Choose a reason for hiding this comment

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

Yay, helper functions!

Comment on lines +75 to +90
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"

Choose a reason for hiding this comment

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

Excellent!

Comment on lines +95 to +102
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

Choose a reason for hiding this comment

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

Excellent!

Comment on lines +119 to +121
response_body = response.get_json()
assert response.status_code == 404
assert not response_body

Choose a reason for hiding this comment

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

Excellent!

Comment on lines +126 to +132
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() == []

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

Choose a reason for hiding this comment

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

Excellent!

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