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 - Esther Annorzie #96

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

Conversation

estherannorzie
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 Esther! I've left comments and a couple questions, please take a look and reach out if you have questions or need clarifications on any of the feedback 😊

@@ -136,7 +136,7 @@ As a client, I want to be able to make a `GET` request to `/tasks/1` when there

As a client, I want to be able to make a `PUT` request to `/tasks/1` when there is at least one saved task with this request body:

```json
```jso

Choose a reason for hiding this comment

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

As we build our skills, something to fold into our process should be reviewing our code when we open PRs to make sure we haven't made unintended changes to other files.

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

from .goal_routes import bp
app.register_blueprint(bp)

Choose a reason for hiding this comment

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

Great choice to divide the routes into their own files!

Comment on lines +36 to +37
return make_response(jsonify({"id": goal.goal_id,
"task_ids": tasks_list}))
Copy link

@kelsey-steven-ada kelsey-steven-ada May 16, 2022

Choose a reason for hiding this comment

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

Nice line wrapping! Though it takes more lines, another way we could format this to help the structure be really clear at a quick glance might be:

    return make_response(
        jsonify({
            "id": goal.goal_id, 
            "task_ids": tasks_list
        })
    )

@bp.route("/<goal_id>", methods=("GET",))
def read_goal(goal_id):
goal = validate_goal_id(goal_id)
return make_response(jsonify({"goal": goal.to_dict()}))

Choose a reason for hiding this comment

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

Notice the pattern of calling make_response(jsonify(...) used by many of the functions in goal_routes.py and task_routes.py. We could make another helper function in routes_helper.py that takes an optional response code and use it across all these functions, similar to the create_message helper function that handles abort(...) calls.

def get_success_response(response_data, response_code = 200):
    return make_response(jsonify(response_data), response_code)

def read_specific_goal_tasks(goal_id):
goal = validate_goal_id(goal_id)

goal_tasks = [Task.to_dict(task) for task in goal.tasks]

Choose a reason for hiding this comment

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

Great use of list comprehensions across the code!

# *****************************************************************
# **Complete test with assertion about response body***************
# *****************************************************************
assert response_body == {"details": "Task 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 here that the database has no records or that there is no record with an ID of 1.

# *****************************************************************
# **Complete test with assertion about response body***************
# *****************************************************************

assert Task.query.all() == []
assert response_body == {"details": "Task not found" }

Choose a reason for hiding this comment

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

The feedback on line 140 applies here and to the following tests in other files around missing tasks.

Comment on lines +60 to +63
assert response.status_code == 404
# assertion 2 goes here
assert response_body == {"details": "Goal not found"}
assert Goal.query.all() == []

Choose a reason for hiding this comment

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

Nice assertions!

# assertion 2 goes here
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 the response body on the line below, we could omit this specific check for goal in the response body.

# *****************************************************************
# **Complete test with assertion about response body***************
# *****************************************************************
assert Goal.query.get(1) == None

Choose a reason for hiding this comment

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

Nice check to confirm 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