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

Paper-Ruthie Newman #71

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

Conversation

RuthieRNewman
Copy link

No description provided.

…el in task.py and defines Goal model in goal.py.
…te a one to many relationship between the two models.
…e method to Task model that generates a JSON with goal_id included in response body, adds response that posts a message to Slack task-notification channel on the task-list-api workspace when user completes a task and sends a patch request to tasks/<task_id> in routes.py.
…py and goal.py and refactors code in routes.py to use from_json instance methods in goal and task endpoints for PUT request.
… in def mark_complete function in routes.py.
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.

Overall nice work Ruthie. I left a few comments, mostly minor things that you seem to have changed just prior to submitting (which caused tests to fail). Let me know what questions you have and I'm happy to go over them.

Comment on lines +17 to +23
def from_json(request_dict):
# Converts JSON into a new instance of Task
new_goal = Goal(
title = request_dict["title"]
)

return new_goal

Choose a reason for hiding this comment

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

Since this method creates a new Goal, I suggest making it a class method

Suggested change
def from_json(request_dict):
# Converts JSON into a new instance of Task
new_goal = Goal(
title = request_dict["title"]
)
return new_goal
@classmethod
def from_json(cls, request_dict):
# Converts JSON into a new instance of Task
new_goal = Goal(
title = request_dict["title"]
)
return new_goal

'is_complete' : completed
}

def create_json_with_goal_id(self):

Choose a reason for hiding this comment

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

You could make this helper a part of the above create_json function using an if statement to include goal if the goal field exists.

'is_complete' : completed
}

def from_json(request_dict):

Choose a reason for hiding this comment

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

similarly I suggest making it a class method. This way you don't have to make an instance of Task before getting a new instance.

task = Task.from_json({ "title": "blah", "description": "...", "is_complete": True })

Suggested change
def from_json(request_dict):
@classmethod
def from_json(cls, request_dict):

Comment on lines +125 to +135
SLACK_TOKEN = os.environ["SLACK_API_TOKEN"]
slack_channel = "task-notifications"
slack_icon_url = "https://slack.com/api/chat.postMessage"
text = f"Someone just completed the task {task.title}"

response = requests.post('https://slack.com/api/chat.postMessage', {
'token': slack_token,
'channel': slack_channel,
'text': text,
'icon_url': slack_icon_url
}).json()

Choose a reason for hiding this comment

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

Just a note that this would make a great helper function.


response = requests.post('https://slack.com/api/chat.postMessage', {
'token': slack_token,
'channel': slack_channel,

Choose a reason for hiding this comment

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

You forgot to capitalize this. So some tests are failing.

Suggested change
'channel': slack_channel,
'channel': SLACK_TOKEN,

@@ -0,0 +1,37 @@

Choose a reason for hiding this comment

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

I like the idea of a separate file for utility functions, but since you're not using it, take it out of git.

Comment on lines +77 to +79
#This fixture gets called in tests for returning goals sorted by title
@pytest.fixture
def three_goals(app):

Choose a reason for hiding this comment

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

You should probably also have a fixture for 3 tasks.

It's great however that you added your own fixture.

@@ -0,0 +1,69 @@
# #test to get tasks sorted by id

Choose a reason for hiding this comment

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

I just want to note that after I uncommented this code, the tests passed...


ordered_query = Task.query.order_by(Task.title.desc())

elif sort_query == "id":

Choose a reason for hiding this comment

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

I love the optionals!

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