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

Pine - Areeba #73

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

Pine - Areeba #73

wants to merge 15 commits into from

Conversation

AreebaQ
Copy link

@AreebaQ AreebaQ commented Nov 5, 2021

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Well done Areeba, you hit the learning goals here. Well done. I made a few minor comments, but this was a very solid submission. Nice work.

Comment on lines +8 to +9
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError

Choose a reason for hiding this comment

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

The Slack SDK is fine, but you can also do this with the built-in request object from Python.


###################
#Helper functions for tasks
def set_task(request_body):

Choose a reason for hiding this comment

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

Nice helper function!


return new_task

def format_task_dictionary(new_task):

Choose a reason for hiding this comment

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

This function, as I remember you mentioning, would work better as an instance method of the Task class.

task = Task.query.get(task_id)

if task is None:
return make_response("Not Found", 404)

Choose a reason for hiding this comment

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

Just for consistency

Suggested change
return make_response("Not Found", 404)
return make_response(f"Task {task_id} not found", 404)

Comment on lines +114 to +116
task = Task.query.get(task_id)
if task is None:
return make_response(f"Task {task_id} not found", 404)

Choose a reason for hiding this comment

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

I just want to point out that you are repeating this code segment a lot. It would be nice to be able to DRY this up a bit. In the future that might be something to research.

Comment on lines +187 to +192
def format_goal_dictionary(new_goal):
goal = {}
goal['id'] = new_goal.goal_id
goal['title'] = new_goal.title

return goal

Choose a reason for hiding this comment

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

This would also make an excellent model method.


goal = Goal.query.get(goal_id) #grab the specific goal
if goal is None:
return make_response("", 404)

Choose a reason for hiding this comment

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

It would be best to include in the body some indication of why it failed in addition to the response code.

Comment on lines +286 to +290
response = {"id": goal.goal_id, "title": goal.title, "tasks": []}

for task in tasks:
task_dict = format_task_dictionary(task)
response["tasks"].append(task_dict)

Choose a reason for hiding this comment

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

This would make a great helper method in the Goal class.

Comment on lines +90 to +100
# def test_update_task_not_found(client):
# # Act
# response = client.put("/tasks/1", json={
# "title": "Updated Task Title",
# "description": "Updated Test Description",
# })
# response_body = response.get_json()

# # Assert
# assert response.status_code == 404
# assert response_body == None

Choose a reason for hiding this comment

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

Suggested change
# def test_update_task_not_found(client):
# # Act
# response = client.put("/tasks/1", json={
# "title": "Updated Task Title",
# "description": "Updated Test Description",
# })
# response_body = response.get_json()
# # Assert
# assert response.status_code == 404
# assert response_body == None

I think you copied this over to use in writing the goal test, but it's not needed now.

# ---- Complete Assertions Here ----
assert response.status_code == 404
assert response_body == 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.

It might also be good to have tests for goals that have tasks and goals that do not have tasks.

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