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

Delay initial version fetch until there is connectivity #5603

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mdegat01
Copy link
Contributor

@mdegat01 mdegat01 commented Feb 5, 2025

Proposed change

Delay initial fetch of version information if there is no network connectivity on the host until either it has been re-established or the connectivity check has been disabled. This way users that turn on their systems before plugging in the ethernet cable or setting up wifi don't have to reboot or force a reload via the CLI to get started.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to cli pull request:
  • Link to client library pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Ruff (ruff format supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints or add-on configuration are added/changed:

Summary by CodeRabbit

  • New Features

    • Enhanced network connectivity monitoring now delays update data retrieval until a stable, full network connection is confirmed, resulting in a more reliable update process.
    • New event handling for supervisor connectivity changes allows the system to respond to connectivity status updates.
  • Bug Fixes

    • Improved logic for connectivity checks ensures accurate state evaluation and response.
  • Tests

    • Expanded test coverage validates the connectivity-dependent update behavior under varying network conditions.
    • Introduced a new test to ensure proper handling of delayed data fetching based on connectivity state.
    • Updated existing tests to utilize new fixture for unthrottled job execution.

@mdegat01 mdegat01 added the new-feature A new feature label Feb 5, 2025
@mdegat01 mdegat01 requested a review from agners February 5, 2025 03:34
Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

📝 Walkthrough

Walkthrough

The changes update the handling of network connectivity. In the production code, the type of a connectivity variable is changed from a boolean to an integer, and a new asynchronous connectivity check method is added in the updater. The updater’s load method now delays fetching version data until a valid network connection is detected. Additionally, a new enumeration value for connectivity change events is introduced. In the test code, the network manager mock is updated with a flag for connectivity checking, and a new test case is added to validate the delayed fetching behavior based on connectivity.

Changes

Files Change Summary
supervisor/host/network.py, supervisor/updater.py In network.py, the type for connectivity in _check_connectivity_changed is updated from `bool
tests/dbus_service_mocks/network_manager.py, tests/test_updater.py In the network manager mock, a new class attribute connectivity_check_enabled is added and the ConnectivityCheckEnabled property now returns its value. In test_updater.py, a new test function test_delayed_fetch_for_connectivity is introduced to verify that data fetching is delayed until connectivity is established.
supervisor/const.py A new enumeration value SUPERVISOR_CONNECTIVITY_CHANGE is added to the BusEvent class to handle connectivity change events.
supervisor/supervisor.py A new import for BusEvent is added, and the connectivity setter method is modified to fire an event when the connectivity state changes.
supervisor/jobs/__init__.py The _notify_on_job_change method in JobManager is modified to fire events with the entire SupervisorJob object instead of just the job's UUID when a job's status changes.
tests/jobs/test_job_decorator.py The parameters of the start_listener and end_listener functions in the test cases are updated from job_id: str to evt_job: SupervisorJob, enhancing type safety by using the job object directly.
tests/conftest.py A new fixture no_job_throttle is added to remove job throttling for tests. The coresys fixture has been modified to remove the rate limiting decorator from the fetch_data method.
tests/misc/test_tasks.py A new test function test_reload_updater_triggers_supervisor_update is added to verify that an updater reload triggers a supervisor update when there is a version change.
tests/os/test_manager.py The decorator for test_ota_url_generic_x86_64_rename is changed to @pytest.mark.usefixtures("no_job_throttle"), indicating it will now run with the specified fixture.
tests/plugins/test_plugin_manager.py The pytest framework is imported, and the @pytest.mark.usefixtures("no_job_throttle") decorator is applied to the test_load function.
tests/test_supervisor.py The supervisor_unthrottled fixture is removed, simplifying the test setup for test_connectivity_check, which now uses the coresys object directly.

Sequence Diagram(s)

sequenceDiagram
    participant U as Updater
    participant NM as NetworkManager
    participant DBus as DBus Event Source
    participant WS as WebSession

    U->>NM: load() checks current connectivity state
    alt Connectivity check enabled and not fully connected
        U->>DBus: Register _check_connectivity listener
        Note over U: Wait for connectivity change events
    else Fully connected or check disabled
        U->>WS: Fetch version data immediately
    end

    DBus->>U: Trigger _check_connectivity event on change
    alt Connectivity becomes full
        U->>WS: Fetch version data
        U->>DBus: Unregister connectivity listener
    else
        Note over U: Continue listening for connectivity updates
    end
Loading

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 282d620 and 76c7db7.

📒 Files selected for processing (7)
  • tests/conftest.py (2 hunks)
  • tests/jobs/test_job_decorator.py (2 hunks)
  • tests/misc/test_tasks.py (1 hunks)
  • tests/os/test_manager.py (1 hunks)
  • tests/plugins/test_plugin_manager.py (2 hunks)
  • tests/test_supervisor.py (1 hunks)
  • tests/test_updater.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/jobs/test_job_decorator.py
🧰 Additional context used
📓 Path-based instructions (6)
`*/**(html|markdown|md)`: - For instructional content in doc...

*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.

  • Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
  • In step-by-step instructions, front the location phrase in the instructional sentence.
  • In step-by-step instructions, front the 'goal' in the instructional sentence.
  • In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
  • do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
  • tests/test_supervisor.py
  • tests/test_updater.py
  • tests/conftest.py
`*/**(html|markdown|md)`: - Use bold to mark UI strings. - I...

*/**(html|markdown|md): - Use bold to mark UI strings.

  • If "" are used to mark UI strings, replace them by bold.
  • tests/test_supervisor.py
  • tests/test_updater.py
  • tests/conftest.py
`*/**(html|markdown|md)`: - Be brief in your replies and don...

*/**(html|markdown|md): - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"

  • tests/test_supervisor.py
  • tests/test_updater.py
  • tests/conftest.py
`*/**(html|markdown|md)`: - Use sentence-style capitalizatio...

*/**(html|markdown|md): - Use sentence-style capitalization also in headings.

  • tests/test_supervisor.py
  • tests/test_updater.py
  • tests/conftest.py
`*/**(html|markdown|md)`: do not comment on HTML used for ic...

*/**(html|markdown|md): do not comment on HTML used for icons

  • tests/test_supervisor.py
  • tests/test_updater.py
  • tests/conftest.py
`*/**(html|markdown|md)`: Avoid flagging inline HTML for emb...

*/**(html|markdown|md): Avoid flagging inline HTML for embedding videos in future reviews for this repository.

  • tests/test_supervisor.py
  • tests/test_updater.py
  • tests/conftest.py
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build armv7 supervisor
  • GitHub Check: Build armhf supervisor
  • GitHub Check: Build aarch64 supervisor
  • GitHub Check: Run tests Python 3.13.1
🔇 Additional comments (10)
tests/test_supervisor.py (3)

42-44: LGTM! Good test setup improvements.

The changes simplify the test by using coresys directly and properly handling throttling with the no_job_throttle fixture.


50-51: LGTM! Correct initial connectivity state check.

The assertion correctly verifies that the supervisor's initial connectivity state is True.


53-55: LGTM! Comprehensive connectivity state verification.

The test effectively verifies that the connectivity state updates correctly after the check, covering both success and failure scenarios through parameterization.

tests/plugins/test_plugin_manager.py (1)

5-6: LGTM!

The addition of the no_job_throttle fixture aligns with the test infrastructure changes across other files.

Also applies to: 39-39

tests/test_updater.py (2)

3-17: LGTM!

The new imports support the enhanced testing capabilities for connectivity and async operations.


86-131: Well-structured test for connectivity-based version fetch!

The test effectively validates that:

  1. Initial version fetch is skipped when there's no connectivity
  2. Version fetch occurs when connectivity is restored
  3. Uses event-based waiting instead of sleep loops

The implementation shows good testing practices by avoiding timing-based assertions.

tests/os/test_manager.py (1)

19-19: LGTM!

The addition of the no_job_throttle fixture maintains consistency with the test infrastructure changes.

tests/misc/test_tasks.py (1)

174-214: Well-designed test for updater reload behavior!

The test effectively validates:

  1. No update is triggered when version remains unchanged
  2. Update is triggered when a new version is detected
  3. Uses proper mocking and context management

The implementation demonstrates good testing practices with clear setup and assertions.

tests/conftest.py (2)

764-768: LGTM! Well-implemented test fixture.

The no_job_throttle fixture effectively removes job throttling by patching Job.last_call to return datetime.min. This is a clean way to bypass throttling in tests.


5-5: LGTM! Import correctly placed.

The datetime import is appropriately placed with other standard library imports.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

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.

Copy link
Contributor

@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

🧹 Nitpick comments (2)
supervisor/updater.py (1)

200-220: Consider adding error handling for the fetch operation.

While the implementation correctly handles connectivity state changes, the fetch operation in a suppressed context might hide important errors.

Consider this alternative implementation:

 async def _check_connectivity(
     self, interface: str, changed: dict[str, Any], invalidated: list[str]
 ):
     """Check if connectivity is true and fetch data."""
     if interface != DBUS_IFACE_NM:
         return

     connectivity_check: bool | None = changed.get(DBUS_ATTR_CONNECTION_ENABLED)
     connectivity: bool | None = changed.get(DBUS_ATTR_CONNECTIVITY)

     # If there's no connectivity checks, stop waiting for connection
     # Else when host says we're online, attempt to fetch version data and disable listener
     if (
         not connectivity_check
         or connectivity == ConnectivityState.CONNECTIVITY_FULL
     ):
         self.sys_dbus.network.dbus.properties.off_properties_changed(
             self._check_connectivity
         )
-        with suppress(UpdaterError):
-            await self.fetch_data()
+        try:
+            await self.fetch_data()
+        except UpdaterError as err:
+            _LOGGER.warning("Failed to fetch version data: %s", err)
tests/test_updater.py (1)

81-114: Consider adding more test cases for comprehensive coverage.

While the current test cases cover the basic scenarios, consider adding these additional cases:

  • Connectivity transitions from NONE to LIMITED
  • Connectivity transitions from LIMITED to FULL
  • Multiple connectivity state changes

Add these test cases to the parameterization:

 @pytest.mark.parametrize(
     ("connectivity", "check_enabled"),
     [
         (ConnectivityState.CONNECTIVITY_FULL, True),
         (ConnectivityState.CONNECTIVITY_NONE, False),
+        (ConnectivityState.CONNECTIVITY_LIMITED, True),
+        (ConnectivityState.CONNECTIVITY_PORTAL, True),
     ],
 )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9164d35 and c81f9c6.

📒 Files selected for processing (4)
  • supervisor/host/network.py (1 hunks)
  • supervisor/updater.py (4 hunks)
  • tests/dbus_service_mocks/network_manager.py (2 hunks)
  • tests/test_updater.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
`*/**(html|markdown|md)`: - For instructional content in doc...

*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.

  • Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
  • In step-by-step instructions, front the location phrase in the instructional sentence.
  • In step-by-step instructions, front the 'goal' in the instructional sentence.
  • In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
  • do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
  • supervisor/updater.py
  • tests/test_updater.py
`*/**(html|markdown|md)`: - Use bold to mark UI strings. - I...

*/**(html|markdown|md): - Use bold to mark UI strings.

  • If "" are used to mark UI strings, replace them by bold.
  • supervisor/updater.py
  • tests/test_updater.py
`*/**(html|markdown|md)`: - Be brief in your replies and don...

*/**(html|markdown|md): - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"

  • supervisor/updater.py
  • tests/test_updater.py
`*/**(html|markdown|md)`: - Use sentence-style capitalizatio...

*/**(html|markdown|md): - Use sentence-style capitalization also in headings.

  • supervisor/updater.py
  • tests/test_updater.py
`*/**(html|markdown|md)`: do not comment on HTML used for ic...

*/**(html|markdown|md): do not comment on HTML used for icons

  • supervisor/updater.py
  • tests/test_updater.py
`*/**(html|markdown|md)`: Avoid flagging inline HTML for emb...

*/**(html|markdown|md): Avoid flagging inline HTML for embedding videos in future reviews for this repository.

  • supervisor/updater.py
  • tests/test_updater.py
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Run tests Python 3.13.1
  • GitHub Check: Build armv7 supervisor
  • GitHub Check: Build armhf supervisor
  • GitHub Check: Build aarch64 supervisor
🔇 Additional comments (5)
supervisor/updater.py (1)

60-68: LGTM! Delay version fetch until connectivity is established.

The implementation correctly delays the initial version fetch when there's no network connectivity, setting up a listener for connectivity changes.

supervisor/host/network.py (1)

151-151: LGTM! Type change aligns with ConnectivityState enum.

The type change from bool | None to int | None correctly matches the DBUS interface's connectivity state values.

tests/dbus_service_mocks/network_manager.py (1)

25-25: LGTM! Mock correctly implements connectivity check control.

The connectivity_check_enabled attribute allows tests to control the connectivity check state.

tests/test_updater.py (2)

95-103: LGTM! Test correctly verifies delayed fetch behavior.

The test properly sets up the initial state and verifies that no fetch occurs without connectivity.


105-114: LGTM! Test correctly verifies fetch on connectivity change.

The test properly verifies that version information is fetched when connectivity is established or checks are disabled.

supervisor/updater.py Outdated Show resolved Hide resolved
supervisor/updater.py Outdated Show resolved Hide resolved
Copy link
Contributor

@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

🧹 Nitpick comments (2)
tests/test_updater.py (2)

106-110: Add delay between network change and ping to prevent race conditions.

The test might be susceptible to race conditions as it immediately pings after emitting the property change.

Add a small delay to ensure the property change is processed:

     network_manager_service.emit_properties_changed(
         {"Connectivity": connectivity.value, "ConnectivityCheckEnabled": check_enabled}
     )
+    await asyncio.sleep(0.1)  # Allow time for property change to be processed
     await network_manager_service.ping()

111-114: Use URL_TEST constant instead of hardcoded URL.

The test uses a hardcoded URL for assertion while the same URL is defined as URL_TEST constant at the top of the file.

Apply this diff to use the constant:

     assert (
         coresys.websession.get.call_args[0][0]
-        == "https://version.home-assistant.io/stable.json"
+        == URL_TEST
     )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c81f9c6 and 0f05dc8.

📒 Files selected for processing (1)
  • tests/test_updater.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
`*/**(html|markdown|md)`: - For instructional content in doc...

*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.

  • Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
  • In step-by-step instructions, front the location phrase in the instructional sentence.
  • In step-by-step instructions, front the 'goal' in the instructional sentence.
  • In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
  • do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
  • tests/test_updater.py
`*/**(html|markdown|md)`: - Use bold to mark UI strings. - I...

*/**(html|markdown|md): - Use bold to mark UI strings.

  • If "" are used to mark UI strings, replace them by bold.
  • tests/test_updater.py
`*/**(html|markdown|md)`: - Be brief in your replies and don...

*/**(html|markdown|md): - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"

  • tests/test_updater.py
`*/**(html|markdown|md)`: - Use sentence-style capitalizatio...

*/**(html|markdown|md): - Use sentence-style capitalization also in headings.

  • tests/test_updater.py
`*/**(html|markdown|md)`: do not comment on HTML used for ic...

*/**(html|markdown|md): do not comment on HTML used for icons

  • tests/test_updater.py
`*/**(html|markdown|md)`: Avoid flagging inline HTML for emb...

*/**(html|markdown|md): Avoid flagging inline HTML for embedding videos in future reviews for this repository.

  • tests/test_updater.py
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Build amd64 supervisor
  • GitHub Check: Build armv7 supervisor
  • GitHub Check: Build armhf supervisor
  • GitHub Check: Build aarch64 supervisor
  • GitHub Check: Run tests Python 3.13.1
🔇 Additional comments (1)
tests/test_updater.py (1)

3-3: LGTM! Import changes are appropriate.

The new imports support the connectivity testing requirements.

Also applies to: 9-9, 11-13

tests/test_updater.py Outdated Show resolved Hide resolved
@mdegat01 mdegat01 changed the title Connectivity for version fetch Delay initial version fetch until there is connectivity Feb 5, 2025
Copy link
Member

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

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

nice

Comment on lines -216 to +218
self.sys_bus.fire_event(BusEvent.SUPERVISOR_JOB_START, job.uuid)
self.sys_bus.fire_event(BusEvent.SUPERVISOR_JOB_START, job)
if value is True:
self.sys_bus.fire_event(BusEvent.SUPERVISOR_JOB_END, job.uuid)
self.sys_bus.fire_event(BusEvent.SUPERVISOR_JOB_END, job)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I realize this feels unrelated. As it turns out, trying to use these in test made me realize they are entirely useless. The listener only receives a uuid and it can't actually count on the job still being around to look up more info about it, so there's really no way to reliably know what job started/ended. Passing the actual job in the event makes these useful (and it was needed in the test)

Copy link
Contributor

@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

🔭 Outside diff range comments (1)
tests/jobs/test_job_decorator.py (1)

1199-1206: Update event listener parameter types for consistency.

The event listeners in test_job_scheduled_at still use str parameter type while similar listeners in test_job_scheduled_delay have been updated to use SupervisorJob.

Apply this diff to maintain consistency:

-async def start_listener(job_id: str):
+async def start_listener(evt_job: SupervisorJob):
    nonlocal started
-    started = started or job_id == job.uuid
+    started = started or evt_job.uuid == job.uuid

-async def end_listener(job_id: str):
+async def end_listener(evt_job: SupervisorJob):
    nonlocal ended
-    ended = ended or job_id == job.uuid
+    ended = ended or evt_job.uuid == job.uuid
🧹 Nitpick comments (1)
tests/test_updater.py (1)

110-110: Add cleanup for event listener registration.

The event listener is registered but never unregistered, which could affect other tests. Consider using a fixture or adding cleanup code.

+    try:
         coresys.bus.register_event(BusEvent.SUPERVISOR_JOB_START, find_fetch_data_job_start)
+        # ... rest of the test ...
+    finally:
+        coresys.bus.unregister_event(BusEvent.SUPERVISOR_JOB_START, find_fetch_data_job_start)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52d713f and a6c9644.

📒 Files selected for processing (3)
  • supervisor/jobs/__init__.py (1 hunks)
  • tests/jobs/test_job_decorator.py (1 hunks)
  • tests/test_updater.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
`*/**(html|markdown|md)`: - For instructional content in doc...

*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.

  • Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
  • In step-by-step instructions, front the location phrase in the instructional sentence.
  • In step-by-step instructions, front the 'goal' in the instructional sentence.
  • In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
  • do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
  • tests/test_updater.py
`*/**(html|markdown|md)`: - Use bold to mark UI strings. - I...

*/**(html|markdown|md): - Use bold to mark UI strings.

  • If "" are used to mark UI strings, replace them by bold.
  • tests/test_updater.py
`*/**(html|markdown|md)`: - Be brief in your replies and don...

*/**(html|markdown|md): - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"

  • tests/test_updater.py
`*/**(html|markdown|md)`: - Use sentence-style capitalizatio...

*/**(html|markdown|md): - Use sentence-style capitalization also in headings.

  • tests/test_updater.py
`*/**(html|markdown|md)`: do not comment on HTML used for ic...

*/**(html|markdown|md): do not comment on HTML used for icons

  • tests/test_updater.py
`*/**(html|markdown|md)`: Avoid flagging inline HTML for emb...

*/**(html|markdown|md): Avoid flagging inline HTML for embedding videos in future reviews for this repository.

  • tests/test_updater.py
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build armv7 supervisor
  • GitHub Check: Build armhf supervisor
  • GitHub Check: Build aarch64 supervisor
  • GitHub Check: Run tests Python 3.13.1
🔇 Additional comments (4)
tests/test_updater.py (2)

3-18: LGTM!

The imports are well-organized and provide the necessary modules for testing network connectivity functionality.


86-134: LGTM! Well-structured test implementation.

The test effectively validates the delayed version fetch behavior using events instead of sleep loops. The staged testing approach (no connectivity → restored connectivity) with clear comments makes the test intent obvious.

supervisor/jobs/__init__.py (1)

216-218: LGTM! Enhanced event payload with full job context.

The change to pass the entire SupervisorJob object instead of just the UUID provides more context to event listeners, which is a better practice for event-driven systems.

tests/jobs/test_job_decorator.py (1)

1147-1154: LGTM! Updated event listener parameter types.

The change to use SupervisorJob instead of str for event listener parameters improves type safety and aligns with the changes in the event firing logic.

@mdegat01 mdegat01 force-pushed the connectivity-for-version-fetch branch from a6c9644 to 282d620 Compare February 6, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants