Skip to content

Test coverage - #16

Closed
flangelo wants to merge 9 commits into
Kegbot:masterfrom
flangelo:test-coverage
Closed

Test coverage#16
flangelo wants to merge 9 commits into
Kegbot:masterfrom
flangelo:test-coverage

Conversation

@flangelo

Copy link
Copy Markdown

No description provided.

flangelo added 9 commits June 11, 2026 18:03
Prevents the daemon from crashing when a corrupted/truncated message
arrives during high-frequency flow pulse bursts.
python:3-alpine now resolves to 3.14, which newer pipenv rejects as
an ambiguous match against `python_version = "3"` in --deploy mode.
pipenv 2024+ rejects python_version = "3" as an ambiguous match
against 3.12.x in --deploy mode. Pin to <2024 to restore prior behavior.
Python 3.12 removed the `imp` module; the `future` package (and other
kegbot deps) still depend on it, causing a crash at startup. Python 3.11
retains `imp` and is supported until 2027.
Thread.isAlive() was removed in Python 3.9; is_alive() is the replacement.
Stage 1 installs pipenv, exports requirements, builds a venv, and
installs the package. Stage 2 copies only the venv and bin/ scripts,
dropping pipenv, curl, and all build cache — 211 MB → 161 MB.
Surfaced while adding test coverage:

- TokenRecord defined only __cmp__, which Python 3 ignores, so equality
  fell back to identity. AuthenticationManager._TokenRemoved therefore
  never matched the stored record and silently no-op'd, leaving captive
  auth flows running after token removal. Add __eq__ based on AsTuple().
- TapManager._RemoveTap referenced self.logger (not self._logger) and
  self._meters (which only exists on FlowManager) — two AttributeErrors.
- Tap defined __eq__ without __hash__, making it unhashable under
  Python 3. Add __hash__ based on AsTuple().
Raise source coverage from ~58% to 85% (14 -> 77 tests):

- New suites: backend, kegnet, kbevent, util, kb_threads, plus expanded
  manager and kegbot env tests. All I/O (Redis, Kegbot API, threads) is
  mocked, so the suite needs no external services.
- Add a `test` stage to the Dockerfile (FROM builder AS test) mirroring
  kegbot-server: installs pytest/coverage, re-installs the package
  editable so coverage measures the source tree, and defaults to
  `coverage run -m pytest && coverage report --fail-under=80`.
- Point CI (pybuild.yml) at `docker build --target test`, exercising the
  real image build. Drop the now-unneeded MySQL/Redis services since the
  suite mocks all I/O.
- Remove the stale Travis config (Python 3.8); GitHub Actions is the
  active CI and the two diverging configs caused version drift.
- Add pytest.ini and .coveragerc; ignore .coverage / .pytest_cache.
- Document the recommended test workflow in CLAUDE.md.
@flangelo flangelo closed this Jun 19, 2026
@flangelo
flangelo deleted the test-coverage branch June 19, 2026 04:12
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