Skip to content

Possum-Divya-task-list-api#33

Open
divya42536 wants to merge 7 commits intoAda-C24:mainfrom
divya42536:main
Open

Possum-Divya-task-list-api#33
divya42536 wants to merge 7 commits intoAda-C24:mainfrom
divya42536:main

Conversation

@divya42536
Copy link
Copy Markdown

No description provided.

Comment thread app/models/goal.py
Comment thread app/models/goal.py Outdated
Comment thread app/models/task.py Outdated
Comment thread app/models/task.py Outdated
Comment on lines +15 to +16
completed_at : Mapped[datetime | None]
goal_id: Mapped[Optional[int]] = mapped_column(ForeignKey("goal.id"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You use two different styles of syntax for declaring an attribute as optional that essentially get treated the same by SQLAlchemy under the hood: [type|None] and Mapped[Optional[type]]. Would prefer that you stick to one style for consistency.

Comment thread app/models/task.py
Comment thread tests/test_wave_07.py Outdated
Comment on lines +103 to +106
new_goal = Goal(title="Wake up in morning")
goal_dict = new_goal.to_dict()

assert goal_dict["id"] is None
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This test case tests the error behavior related to validate_model when the function is passed an ID that doesn't exist. Instead of creating a goal, we should be checking that the error response we get back validate_model has the status code we expect to receive and that the response body contains the values we expect.

Have a look at what e on line 100 is by using your debugger.

This test needs to be updated.

Comment thread tests/test_wave_07.py Outdated
Comment on lines +143 to +148
new_task = Task(title="",description="")
task_dict = new_task.to_dict()

response = e.value.get_response()
assert response.status_code == 400
assert response.get_json() == {"details": "Invalid data"}

assert task_dict["title"] == ""
assert task_dict["description"] == ""
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same as my comment above. These lines of code don't actually test the scenario described by the test name test_route_utilities_create_model_with_task_missing_title.

See on lines 134-137 we create an invalid request body that we pass to create_model and we want to test that the function behaves as we expect.

Do we get the right status code back? Does the response body look like how we expect it to look?

Debug this test and inspect what e on line 140 is. How can you use that to write assertions?

Comment thread tests/test_wave_07.py Outdated
Comment on lines +176 to +180
response = e.value.get_response()

raise Exception("Complete test with assertion status code and response body")
assert response.status_code == 400
response_body = response.get_data(as_text=True)
assert "message" in response_body
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread tests/test_wave_07.py Outdated
Comment on lines +181 to +183
{
"message":"goal_title is missing."
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is this dictionary for? Did you intend to write an assertion about it related to the response body?

Comment thread app/models/task.py Outdated
Comment on lines +35 to +38
title= task_data["title"],
description= task_data["description"],
completed_at= task_data.get("completed_at"),
goal_id= task_data.get("goal_id",None)) No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👀❗️ Take care to check that your code follows correct formatting. This is direct concern related to how folks perform at internship. At internship and at work, code with incorrect spacing or blank lines looks sloppy and people could pass judgement about someone's skill based on how their code looks.

Suggested change
title= task_data["title"],
description= task_data["description"],
completed_at= task_data.get("completed_at"),
goal_id= task_data.get("goal_id",None))
title=task_data["title"],
description= ask_data["description"],
completed_at=task_data.get("completed_at"),
goal_id=task_data.get("goal_id",None))

divya42536 and others added 4 commits November 15, 2025 12:58
Co-authored-by: Ashley Yang <ashley.minghui@gmail.com>
Co-authored-by: Ashley Yang <ashley.minghui@gmail.com>
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