Skip to content

Add tests - #8

Open
marcogobbo wants to merge 1 commit into
mainfrom
tests
Open

Add tests#8
marcogobbo wants to merge 1 commit into
mainfrom
tests

Conversation

@marcogobbo

Copy link
Copy Markdown
Owner

Add test suite, CI, and main-branch protection

Hardens the project so new features reach main only through a reviewed, CI-passing PR. Adds an automated test suite, a GitHub Actions pipeline, and local pre-commit enforcement.

Tests

Adds a pytest suite (66 tests) covering the pure logic plus light, mocked cog tests:

  • test_uta_parser.py — UTA CGI HTML parser: timestamp parsing + fallback, analog grabs, the rirpresa typo tolerance, season→setpoint routing, alarm/state phrase inference, chiller alarm discrimination, and UtaSnapshot property truth tables.
  • test_proteox_snapshot.pySnapshot.status/is_idle/temperature_value and SensorReading.formatted (heater OFF, N/A, Out of range).
  • test_fridge_config.py — loads the real config/*.yaml, validates pt2_key, and rejects unknown quantities.
  • test_settings.py — env-driven loading: full fridge, incomplete-fridge skip, zero-fridges error, invalid destination type.
  • test_cogs.py— mocked ReportsCog routing/ephemeral-defer and SchedulerCog skip-vs-post decisions (idle+warm, running, idle+cold, LOCAL mode).
  • conftest.py provides shared UTA HTML fixtures; test_units.py extended with magnetic-field, negative, and sub-prefix cases.

Tooling

  • Added black, mypy, and pre-commit as dev dependencies with [tool.black] and a pragmatic [tool.mypy] baseline.
  • .pre-commit-config.yamlruns trailing-whitespace/EOF/yaml checks, black, ruff, and mypy (mypy hook given the project's typed deps so it matches poetry run mypy).

CI (.github/workflows/ci.yml)

Runs on PRs to main:

  • lint — pre-commit (ruff + black + mypy + basic hooks).
  • test (3.11) / test (3.12) — pytest across both Python versions.

Incidental fixes surfaced by the new checks

  • Corrected a wrong unit-test assertion (500 Pa renders as 500.0 Pa, not 0.5 kPa).
  • Removed an unused timezone import in monday.py.
  • Removed stale # type: ignore comments and added a missing assert in proteox.py for a
  • Updated README (Contributing section + corrected the daily-report gating description from mixing-chamber to PT2).

Follow-up (manual, post-merge)

Enable branch protection on main: require a PR, 1 approval, dismiss stale approvals, lint, test (3.11), test (3.12). (Requires the workflow to have run once so the check names
register.)

Verification

pytest (66 passed), ruff, black --check, mypy src, and pre-commit run --all-files all

@marcogobbo marcogobbo added the enhancement New feature or request label Jun 1, 2026
@marcogobbo marcogobbo self-assigned this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant