Skip to content

Improve task validation and add unit tests - #24

Open
makgabomadiba5-coder wants to merge 1 commit into
wethinkcode:mainfrom
makgabomadiba5-coder:makgabomadiba5-coder-fictional-spoon
Open

makgabomadiba5-coder wants to merge 1 commit into
wethinkcode:mainfrom
makgabomadiba5-coder:makgabomadiba5-coder-fictional-spoon

Conversation

@makgabomadiba5-coder

Copy link
Copy Markdown

Why

This PR improves validation and robustness for the TaskManager Python starter and adds unit tests to verify behavior. The goal is to reduce silent failures from invalid inputs (date parsing and enum handling) and to increase confidence through automated tests.

What changed (approach)

  • Replace direct prints on invalid date parsing with structured logger warnings so callers can capture/redirect diagnostic output.
  • Normalize Task.update to accept TaskPriority/TaskStatus as enums, integers, or strings (name or numeric string) and ignore invalid inputs rather than corrupting state.
  • Add unit tests that assert logging for invalid dates, verify JSON save/load round-trip, and validate Task.update normalization.

Why it matters / review notes

  • Changes make the codebase more resilient to a wider set of user inputs and make failures visible via logging rather than silent prints.
  • The Task.update changes intentionally swallow invalid priority/status values; reviewers should confirm this is the desired behavior (alternatively we could raise on invalid input).
  • Logging is configured at module level; consider adding a top-level logging.basicConfig in the CLI entrypoint so warnings are visible when running the CLI interactively.

Files touched

  • python/TaskManager/task_manager.py — use logger.warning instead of print for invalid date inputs
  • python/TaskManager/models.py — added normalization logic in Task.update
  • python/TaskManager/tests/test_task_manager.py — added tests for invalid-date logging, JSON roundtrip, and update normalization

Testing

  • Ran the Python test suite locally: 34 tests, all passing.

Notes

  • No behavior changes to JavaScript/Java examples. Persistence remains file-based (tasks.json).

N/A

Replaced invalid-date prints with logger.warning; normalized Task.update to accept ints/strings/enums; added three unit tests (invalid-date logging, JSON roundtrip, update normalization).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@makgabomadiba5-coder
makgabomadiba5-coder marked this pull request as draft August 10, 2026 18:34
@makgabomadiba5-coder
makgabomadiba5-coder marked this pull request as ready for review August 10, 2026 18:36
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.

1 participant