Unit tests for conf.py, and add it to the coverage gate #25

Open
opened 2026-10-03 10:59:13 -03:00 by marcos-mendez · 1 comment
marcos-mendez commented 2026-10-03 10:59:13 -03:00 (Migrated from github.com)

Context
conf.py reads confconsole.conf (default_nic, publicip_cmd, networking, copy_paste) and writes default_nic back. No test imports it today, so it is at 0 percent and outside the CI gate. It is step 3 of the test plan in COVERAGE.md.

What to do

  1. Run the tests locally:
    python3 -m venv .venv && . .venv/bin/activate
    pip install pytest coverage pyyaml
    PYTHONPATH=. python -m coverage run --branch --source=conf -m pytest -q tests
    python -m coverage report --show-missing
    
  2. Add tests/test_conf.py. Use pytest's tmp_path and monkeypatch.chdir so path() finds a scratch conf/confconsole.conf; nothing may touch /etc. Cover:
    • path(): the file found under conf/, and ConfconsoleConfError when it is missing everywhere.
    • Conf() reading each option, comments and blank lines, networking/copy_paste true and false, autostart ignored, and an illegal line raising ConfconsoleConfError.
    • set_default_nic: replacing an existing line, appending when there is none, keeping comments and other settings, and a file whose last line has no newline.
  3. Add conf to the package: list in .github/workflows/tests.yml.

Done when

  • conf.py is at 100 percent line and branch coverage, conf is in the measured list, and the tests check is green.
  • conf.py is unchanged.

Help
Ask in https://github.com/orgs/Keel-Linux/discussions

**Context** `conf.py` reads `confconsole.conf` (`default_nic`, `publicip_cmd`, `networking`, `copy_paste`) and writes `default_nic` back. No test imports it today, so it is at 0 percent and outside the CI gate. It is step 3 of the test plan in `COVERAGE.md`. **What to do** 1. Run the tests locally: ``` python3 -m venv .venv && . .venv/bin/activate pip install pytest coverage pyyaml PYTHONPATH=. python -m coverage run --branch --source=conf -m pytest -q tests python -m coverage report --show-missing ``` 2. Add `tests/test_conf.py`. Use pytest's `tmp_path` and `monkeypatch.chdir` so `path()` finds a scratch `conf/confconsole.conf`; nothing may touch `/etc`. Cover: - `path()`: the file found under `conf/`, and `ConfconsoleConfError` when it is missing everywhere. - `Conf()` reading each option, comments and blank lines, `networking`/`copy_paste` true and false, `autostart` ignored, and an illegal line raising `ConfconsoleConfError`. - `set_default_nic`: replacing an existing line, appending when there is none, keeping comments and other settings, and a file whose last line has no newline. 3. Add `conf` to the `package:` list in `.github/workflows/tests.yml`. **Done when** - `conf.py` is at 100 percent line and branch coverage, `conf` is in the measured list, and the `tests` check is green. - `conf.py` is unchanged. **Help** Ask in https://github.com/orgs/Keel-Linux/discussions
riddhigupta1110 commented 2026-10-08 03:19:36 -03:00 (Migrated from github.com)

I’d like to work on this issue and add the missing test coverage. Could you please assign it to me?

I’d like to work on this issue and add the missing test coverage. Could you please assign it to me?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Keel-Linux/confconsole#25
No description provided.