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

Sea Turtles - Tiffini H. #99

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

Conversation

tiffinihyatt
Copy link

No description provided.

Copy link

@kelsey-steven-ada kelsey-steven-ada left a comment

Choose a reason for hiding this comment

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

Great work pulling together many concepts in this project Tiffini! Please take a look at the feedback when you have time, and reach out if you have questions or could use clarifications on anything 😊

Comment on lines +33 to +37
from .task_routes import tasks_bp
app.register_blueprint(tasks_bp)

from .goal_routes import goals_bp
app.register_blueprint(goals_bp)

Choose a reason for hiding this comment

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

Nice, I like the choice to divide the routes into their own files!

@@ -0,0 +1,90 @@
from flask import Blueprint, request, jsonify, make_response, abort

Choose a reason for hiding this comment

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

It looks like the abort function isn't directly used in this file anymore, so we should remove the import as part of our clean up & refactor steps.

Copy link
Author

Choose a reason for hiding this comment

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

Oh man, I thought I caught all of those! Thanks, Kelsey!

Comment on lines +15 to +16
if self.tasks:
goal_dict["tasks"] = [task.task_id for task in self.tasks]

Choose a reason for hiding this comment

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

Nice way to add the attribute that won't always exist!


if self.tasks:
goal_dict["tasks"] = [task.task_id for task in self.tasks]
# goal_dict["tasks"] = []

Choose a reason for hiding this comment

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

We want to make sure to delete commented out code as part of clean up. When we are sharing a codebase with other folks, it's unclear what the intention of commented out code is, especially without extra comments explaining why it's there. We use versioning tools like git so we can confidently delete code and view our commit history if we need to recover something we wrote prior.

Copy link
Author

Choose a reason for hiding this comment

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

Noted--thank you for catching this!

Comment on lines +19 to +22
if not self.completed_at:
task_dict["is_complete"] = False
else:
task_dict["is_complete"] = True

Choose a reason for hiding this comment

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

It isn't necessary, but we could use a ternary operator here:

task_dict["is_complete"] = True if self.completed_at else False

or the bool function:

task_dict["is_complete"] = bool(self.completed_at)

@@ -0,0 +1,101 @@
from flask import Blueprint, request, jsonify, make_response, abort

Choose a reason for hiding this comment

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

The feedback about abort in goal_routes.py applies here as well.

db.session.delete(task)
db.session.commit()

return make_response({"details": f'Task {task_id} "{task.title}" successfully deleted'})

Choose a reason for hiding this comment

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

Nice, I like the informative messages.

def test_get_task_not_found(client):
# Act
response = client.get("/tasks/1")
response_body = response.get_json()

# Assert
assert response.status_code == 404
assert response_body == {"details": f"Task #1 not found"}

Choose a reason for hiding this comment

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

To ensure we're checking all the relevant data, it might be good to confirm that the database has no records, or that there is no record in the DB with an ID of 1. (This feedback around checking the DB applies to other tests as well.)

# assertion 2 goes here
# assertion 3 goes here
assert response.status_code == 200
assert "goal" in response_body

Choose a reason for hiding this comment

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

Since we check the whole structure of response_body on the line below which confirms that goal is in the response, we could omit this specific check for goal in response_body.

"title": "Updated Goal Title"
}
}
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.

Nice checking the DB contents!

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