Skip to content

Conversation

@sundbean
Copy link

With optional enhancements including additional tests and test configs

sundbean added 30 commits May 5, 2021 19:22
…ncies to include datetime, test wave 3 passing
…e, per instructions, rather than slack_sdk package
…, modifies GET method to /tasks to return goal_id as part of response
…factors routes.py to use new methods to DRY code
@sundbean sundbean changed the title Whit - Paper Paper - Whit May 13, 2021
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! You hit the learning goals here. Nice work. I like helper functions and the tests you added. Great job.

title = db.Column(db.String)
tasks = db.relationship('Task', backref='goal', lazy=True)

def to_json(self):

Choose a reason for hiding this comment

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

Great helper method!

task_info['goal_id'] = self.goal_id
return task_info

def from_json(self, request_body):

Choose a reason for hiding this comment

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

Nice!

Comment on lines +12 to +17
def is_task_complete(self):
if not self.completed_at:
return False
return True

def get_task_info(self):

Choose a reason for hiding this comment

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

Great helper methods

else:
tasks = Task.query.all()

return jsonify([task.get_task_info() for task in tasks])

Choose a reason for hiding this comment

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

Nice list comprehension

Comment on lines +42 to +44
sort_query = request.args.get("sort")
sort_by_id_query = request.args.get("sort_by_id")
filter_by_query = request.args.get("filter_by_title")

Choose a reason for hiding this comment

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

Doing the optionals! 😀

Comment on lines +143 to +148
try:
new_goal = Goal(title=request_body['title'])
except KeyError:
return make_response({
"details": "Invalid data"
}, 400)

Choose a reason for hiding this comment

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

Handling exceptions 👍

#### Helper Functions ####
##########################

def post_to_slack(message):

Choose a reason for hiding this comment

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

Great helper function

pytz==2021.1
requests==2.25.1
six==1.15.0
slack-sdk==3.5.1

Choose a reason for hiding this comment

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

Since you're not using this anymore.

Suggested change
slack-sdk==3.5.1

Comment on lines +90 to +93
# This fixture gets called in optional enchancements tests
# that reference "three_goals". This fixture creates three
# goals and saves them in the database
@pytest.fixture

Choose a reason for hiding this comment

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

Great additional fixture!

@@ -0,0 +1,175 @@
def test_get_tasks_sorted_by_id(client, three_tasks):

Choose a reason for hiding this comment

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

Well done with the optional tests!

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