Skip to content
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

log module unit test coverage #260

Merged
merged 11 commits into from
Sep 2, 2024
Merged

log module unit test coverage #260

merged 11 commits into from
Sep 2, 2024

Conversation

NeonDaniel
Copy link
Member

@NeonDaniel NeonDaniel commented Jul 16, 2024

Add docstrings and type annotations to log module
Add test coverage for log rotation
Outline test coverage for added log module functions
Relates to #2

Closes #239
Closes #253

Summary by CodeRabbit

  • New Features

    • Enhanced logging capabilities with the addition of "enclosure" and "admin" services.
    • Improved flexibility in logging configurations.
  • Documentation

    • Added comprehensive documentation and type hints for logging functions.
  • Tests

    • Introduced extensive test cases for log rotation, log level changes, and logging configurations to ensure robust functionality.

Daniel McKnight added 2 commits July 15, 2024 18:19
Add test coverage for log rotation
Outline test coverage for added log module functions
Relates to #2 #239 #233 #250 #253
Copy link

codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 88.46154% with 3 lines in your changes missing coverage. Please review.

Project coverage is 43.87%. Comparing base (ce642ff) to head (6be5c61).
Report is 10 commits behind head on dev.

Files with missing lines Patch % Lines
ovos_utils/log.py 88.46% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #260      +/-   ##
==========================================
+ Coverage   42.27%   43.87%   +1.60%     
==========================================
  Files          31       31              
  Lines        3217     3227      +10     
==========================================
+ Hits         1360     1416      +56     
+ Misses       1857     1811      -46     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Refactor variable in `get_logs_config` for clarity
Refactor `get_logs_config` for more predictable handling of an empty service name
Copy link

coderabbitai bot commented Jul 18, 2024

Walkthrough

The changes enhance logging functionalities within ovos_utils/log.py by adding new service names, improving function signatures with type hints, and refactoring logic for flexibility and clarity. Corresponding test cases in test/unittests/test_log.py were expanded and refined to cover these new capabilities, ensuring robust test coverage and verification of configuration changes.

Changes

File(s) Summary
ovos_utils/log.py Added new services, improved function signatures, refactored logic, and enhanced documentation.
test/unittests/test_log.py Added and refined test cases for log rotation, log initialization, log path retrieval, and log configuration changes.

Assessment against linked issues

Objective Addressed Explanation
New functions are missing test coverage [#239]
Add unit test coverage to ensure config changes are reacted to [#253]

Poem

In the logbook of code so grand,
New services take their stand.
enclosure and admin join the spree,
With tests to ensure all's error-free.
Configs agile, logs rotate with grace,
Bugs and clutter, there's no trace.
Hopping ahead, the rabbit's cheer,
For robust logs, we all revere! 🐇📜


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Daniel McKnight added 3 commits July 17, 2024 17:27
Update `get_log_paths` to check all log names with `-` normalized to `_` (appeared to be the original intent)
Add `enclosure` and `admin` service logs used by Neon and legacy Mycroft/OVOS setups
ovos_utils/log.py Outdated Show resolved Hide resolved
ovos_utils/log.py Outdated Show resolved Hide resolved
…ome well-known values

Update unit test for `get_log_paths`
@NeonDaniel NeonDaniel requested a review from JarbasAl July 18, 2024 19:06
@JarbasAl JarbasAl marked this pull request as ready for review July 18, 2024 19:53
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 70c46a3 and 89db894.

Files ignored due to path filters (1)
  • test/unittests/test_logs/real.log is excluded by !**/*.log
Files selected for processing (2)
  • ovos_utils/log.py (7 hunks)
  • test/unittests/test_log.py (4 hunks)
Additional context used
Ruff
test/unittests/test_log.py

5-5: copy.deepcopy imported but unused

Remove unused import: copy.deepcopy

(F401)

Additional comments not posted (15)
test/unittests/test_log.py (9)

21-21: LGTM!

The test case for reloading the ovos_utils.log module is correctly implemented.


65-109: LGTM!

The test cases for log rotation, including log rotation with backup and multiple log rotations, are comprehensive and correctly implemented.


110-134: LGTM!

The test cases for initializing the service logger with default and configured settings are correctly implemented.


Line range hint 135-154: LGTM!

The test case for logging deprecation warnings is correctly implemented.


Line range hint 155-186: LGTM!

The test case for the deprecated decorator is correctly implemented.


188-213: LGTM!

The test cases for monitoring log level changes are correctly implemented.


214-258: LGTM!

The test cases for getting log configurations with various configurations and overrides are correctly implemented.


259-273: LGTM!

The test cases for getting log paths with different configurations are correctly implemented.


275-306: LGTM!

The test cases for getting log paths and available logs with different configurations are correctly implemented.

ovos_utils/log.py (6)

210-219: LGTM!

The changes to the init_service_logger function, including the type annotation and added documentation, improve the function's clarity and functionality.


Line range hint 227-260: LGTM!

The changes to the get_logs_config function, including the type annotations, added documentation, and refactored logic, improve the function's clarity and functionality.


Line range hint 346-365: LGTM!

The changes to the get_log_path function, including the type annotation and added documentation, improve the function's clarity and functionality.


Line range hint 373-395: LGTM!

The changes to the get_log_paths function, including the type annotation, added documentation, and refactored logic, improve the function's clarity and functionality.


Line range hint 407-416: LGTM!

The changes to the get_available_logs function, including the type annotation and added documentation, improve the function's clarity and functionality.


32-33: Verify the necessity of adding "enclosure" and "admin".

Ensure that the additions of "enclosure" and "admin" to the ALL_SERVICES set are necessary and do not cause any conflicts.

test/unittests/test_log.py Outdated Show resolved Hide resolved
@NeonDaniel NeonDaniel requested a review from a team July 18, 2024 20:02
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 89db894 and a7672b9.

Files selected for processing (1)
  • ovos_utils/log.py (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ovos_utils/log.py

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a7672b9 and 6be5c61.

Files selected for processing (1)
  • test/unittests/test_log.py (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • test/unittests/test_log.py

@JarbasAl JarbasAl merged commit e4a3ff7 into dev Sep 2, 2024
9 checks passed
@JarbasAl JarbasAl deleted the TEST_AddLogTestCoverage branch September 2, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants