-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase unit test coverage to 100% #8
Conversation
71% -> 100%
- Generalize Starlette exception handling in inboard/app/utilities.py: Exceptions are passed to inboard/app/starlettebase/main.py and handled by `on_auth_error()`. - Add test method to verify Starlette exception message returned by inboard/app/starlettebase/main.py - Improve test coverage of inboard/app/utilities.py (93% -> 100%)
89% -> 100% - Remove `ImportError` conditional from `start.configure_logging()`: Python will raise an `ImportError` automatically in this case. - Add test method for incorrect logging module path to test_start.py - Remove exception handling from `start.run_pre_start_script`: Don't yet have a test case in which an exception would be raised. - Condense start.py `__main__` block: Helps avoid replicate method calls when running start.py. Previously some methods were running multiple times (such as `start.configure_logging`). - Add `pragma: no cover` comments to start.py `__main__` block: Methods are tested separately.
00a3319 As in tiangolo/uvicorn-gunicorn-docker, the gunicorn_conf.py had been configured to print a JSON dump of the custom Gunicorn configuration. This is unnecessary, because Gunicorn already outputs its configuration to the logger when `LOG_LEVEL=debug` is used. This commit will remove the exception handling for `logconfig_dict`. The `start.configure_logging` method has its own exception handling. If additional exception handling is ever needed here, the following code could be used: ```py import logging try: logconfig_dict = configure_logging( logging_conf=os.getenv("LOGGING_CONF", "inboard.logging_conf") ) except Exception as e: logger: logging.Logger = logging.getLogger() logger.debug(f"Error loading logging config with Gunicorn: {e}") ```
84% -> 100% - Use same syntax when calculating `max_workers` and `workers_per_core` - Add test method to check worker configuration to test_start.py
- pytest features - pytest plugins - pytest configuration - FastAPI and Starlette testing - test coverage tooling
Sourcery Code Quality Report (beta)✅ Merging this PR will increase code quality in the affected files by 0.03 out of 10.
Here are some functions in these files that still need a tune-up:
Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Let us know what you think of it by mentioning @sourcery-ai in a comment. |
Codecov Report
@@ Coverage Diff @@
## develop #8 +/- ##
=============================================
+ Coverage 85.59% 100.00% +14.40%
=============================================
Files 8 8
Lines 243 223 -20
=============================================
+ Hits 208 223 +15
+ Misses 35 0 -35
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
br3ndonland/inboard#8 - Add version calculation using `importlib.metadata` https://docs.python.org/3/library/importlib.metadata.html - Avoid throwing error if project is not installed (such as in Docker)
Description
PR #7 added test coverage measurement with pytest-cov and Codecov. The initial coverage measurement showed 86% unit test coverage.
This PR will increase the unit test coverage to 100%.
Changes
__init__.py
(2a56650): 71% -> 100% coveragePROCESS_MANAGER
environment variablePROCESS_MANAGER
environment variable is set to either"gunicorn"
or"uvicorn"
PROCESS_MANAGER
Callable
on_auth_error()
.ImportError
conditional fromstart.configure_logging()
: Python will raise anImportError
automatically in this case.test_start.py
start.run_pre_start_script
: Don't yet have a test case in which an exception would be raised.__main__
block: Helps avoid replicate method calls when runningstart.py
. Previously, some methods were running multiple times (such asstart.configure_logging
).pragma: no cover
comments to start.py__main__
block: Methods are tested separately.test_start.py
for default Gunicorn config: Test default configuration and custom configuration with separate test methods.gunicorn_conf.py
had been configured to print a JSON dump of the custom Gunicorn configuration. This is unnecessary, because Gunicorn already outputs its configuration to the logger whenLOG_LEVEL=debug
is used, so the JSON dump will be removed.logconfig_dict
ingunicorn_conf.py
: Thestart.configure_logging
method has its own exception handling.max_workers
andworkers_per_core
ingunicorn_conf.py
test_start.py
to check worker configurationRelated
#4
#7
5b9706f
397638e
b0a36de
735618a
3906b3d
92e6b68
735618a