Skip to content

Add tests, CI workflows, and homeassistant mock for task_tracker#5

Merged
gensyn merged 6 commits intomasterfrom
copilot/add-tests-and-workflows
Mar 10, 2026
Merged

Add tests, CI workflows, and homeassistant mock for task_tracker#5
gensyn merged 6 commits intomasterfrom
copilot/add-tests-and-workflows

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

No tests existed for the integration. This adds comprehensive unit tests for all non-boilerplate code, a minimal homeassistant mock to avoid the full HA dependency, and pylint/CI GitHub workflows.

Test coverage

  • test/test_validate_options.py — 20 tests for options_flow.validate_options(): all default values, boundary conditions (interval ≥ 1, mdi: prefix), and passthrough of valid input
  • test/test_sensor.py — 30 tests for TaskTrackerSensor: __init__, async_update (due-date arithmetic for all interval types), _filter_state_changes, async_sync_todo_list (all 4 add/update/remove/noop branches), async_mark_as_done, async_set_last_done_date
  • test/test_config_flow.pyTaskTrackerConfigFlow.async_step_user: form shown on no input, entry created with correct data/options, options flow delegation
  • test/test_init.pyasync_migrate_entry (v1.1→v1.2 migration, version guards) and get_sensor
  • test/test_button.pybutton.get_sensor: single sensor found, zero sensors, multiple sensors

Homeassistant mock

test/homeassistant_mock/ is a minimal stub of all homeassistant sub-packages imported by the integration (components, config_entries, core, exceptions, helpers, util). Tests inject it via sys.path — same pattern used in gensyn/ssh_command#2.

Infrastructure

  • requirements.txtpython-dateutil and voluptuous (the only non-stdlib, non-HA runtime deps)
  • .github/workflows/test.yml — Python 3.13, installs requirements.txt, runs python -m unittest discover -s test
  • .github/workflows/pylint.yml — Python 3.13, --fail-under=9, --ignore-paths=^test/.*$
  • run_tests.sh — local convenience wrapper using coverage
  • .gitignore — excludes __pycache__, .pyc, coverage artifacts
Original prompt

This section details on the original issue you should resolve

<issue_title>No tests in repository</issue_title>
<issue_description>Create tests for all non-boilerplate code use https://github.com/gensyn/HomeAssistantPlugin as a template for tests and also add the pylint and test GitHub workflows from that repo to this. Do not introduce a new requirements_unittest.txt but use the existing requirements.txt. Mock everything relating to homeassistant as needed.

Also have a look at this very similar PR: gensyn/ssh_command#2</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits March 9, 2026 15:12
Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com>
Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com>
Copilot AI changed the title [WIP] Create tests and workflows for existing code Add tests, CI workflows, and homeassistant mock for task_tracker Mar 9, 2026
@gensyn gensyn marked this pull request as ready for review March 9, 2026 15:31
@gensyn gensyn merged commit b29eb73 into master Mar 10, 2026
6 checks passed
@gensyn gensyn deleted the copilot/add-tests-and-workflows branch March 12, 2026 11:42
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.

No tests in repository

2 participants