Skip to content

Task List API - Jasmine S.#134

Open
bunnaery wants to merge 32 commits intoAda-C19:mainfrom
bunnaery:main
Open

Task List API - Jasmine S.#134
bunnaery wants to merge 32 commits intoAda-C19:mainfrom
bunnaery:main

Conversation

@bunnaery
Copy link
Copy Markdown

No description provided.

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

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

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

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

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

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 No newline at end of file
Copy link
Copy Markdown

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

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

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

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() == []
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Excellent!


# Assert
assert response.status_code == 404
assert not response_body
Copy link
Copy Markdown

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