Skip to content

Start of test-suite rewrite#262

Merged
ketiltrout merged 3 commits intochime-upgradefrom
test_rudiments
Apr 11, 2026
Merged

Start of test-suite rewrite#262
ketiltrout merged 3 commits intochime-upgradefrom
test_rudiments

Conversation

@ketiltrout
Copy link
Copy Markdown
Member

@ketiltrout ketiltrout commented Apr 9, 2026

Unit tests for cocod up to the end of config file loading.

That is, up to (but not including) the point where the State is created. This is includes unit tests for all of coco/config.py and a bit of coco/core.py.

The revamped test suite uses pyfakefs for test isolation. I've written a small number of fixtures in the pytest-default conftest.py file to simplify tests.

Specific fixes / changes:

  • Removed all the top-level imports into coco/__init__.py which might have made sense if coco were being used as a library package, but doesn't seem helpful here and is causing problems with circular imports.
  • If an explicitly-given config file (i.e. via -c on the command line and/or the COCO_CONFIG_FILE environmental variable) is missing, cocod now exits with a fatal error. Previously it would silently ignore these missing files.
  • I/O, character encoding and YAML errors in config files and endpoints now produce meaningful error messages.
  • An invalid "log_level" in the config is now handled gracefully via fatal error.
  • An early exit of cocod no longer crashes on exit with a AttributeError (due to redis_sync not being defined early enough).
  • Config errors noticed by cocod are now reported using click.ClickException instead of coco's ConfigError for proper CLI exit.

This removes all the imports into the top-level.  They're not necessary
here and are producing circular import errors.
That is, up to (but not including) the point where the `State` is created.
This is includes unit tests for all of `coco/config.py` and a bit of
`coco/core.py`.

The revamped test suite uses `pyfakefs` for test isolation.  I've
written a small number of fixtures in the pytest-default `conftest.py`
file to simplify tests.

Specific fixes / changes:

* If an explicitly-given config file (i.e. via `-c` on the command line
  and/or the `COCO_CONFIG_FILE` environmental variable) is missing,
  cocod now exits with a fatal error.  Previously it would silently
  ignore these missing files.
* I/O, character encoding and YAML errors in config files and endpoints
  now produce meaningful error messages.
* An invalid "log_level" in the config is now handled gracefully via
  fatal error.
* An early exit of `cocod` no longer crashes on exit with a `NameError`
  (due to `redis_sync` not being defined early enough).
* Config errors noticed by `cocod` are now reported using
  `click.ClickException` instead of coco's `ConfigError` for proper CLI
  exit.
Comment thread .github/workflows/main.yaml Outdated
Comment thread coco/core.py Outdated
@ketiltrout
Copy link
Copy Markdown
Member Author

ketiltrout commented Apr 10, 2026

For the test failures, see chime-experiment/comet#118

@ketiltrout ketiltrout merged commit cc1e8f2 into chime-upgrade Apr 11, 2026
7 of 10 checks passed
@ketiltrout ketiltrout deleted the test_rudiments branch April 11, 2026 00:47
ketiltrout added a commit that referenced this pull request Apr 11, 2026
Instead of the monkeypatching of PyYAML's `SafeLoader`, there's now just
a wrapper around the `safe_load` call that does post-processing on the
returned `dict`.

Requires #262
ketiltrout added a commit that referenced this pull request Apr 16, 2026
Specific fixes:
* defer compiling the TIMEDELTA regex until first use.
* catch various input errors to `Host`
* removed dependency on `atomicwrites` (unmaintained since 2022)

Requires #262
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.

2 participants