Closed ludeeus closed 1 month ago
custom_components/hacs/repositories/plugin.py (6)
`17-17`: Type hint import is correctly scoped under `TYPE_CHECKING` to avoid runtime overhead. --- `65-65`: The asynchronous methods `async_post_installation` and `async_post_uninstall` now handle dashboard resources, aligning with the PR's objectives. Also applies to: 67-69 --- `149-167`: The methods `generate_dashboard_resource_hacstag`, `generate_dashboard_resource_namespace`, and `generate_dashboard_resource_url` are well-implemented for generating resource identifiers. --- `171-191`: The method `_get_resource_handler` effectively handles various error scenarios related to resource access. The logging improvements suggested in previous comments have been correctly implemented. --- `195-221`: The methods `update_dashboard_resources` and `remove_dashboard_resources` are crucial for managing the lifecycle of dashboard resources. They correctly utilize the `_get_resource_handler` method to ensure resources are managed appropriately. --- `5-5`: Ensure the `re` module is used appropriately in the file.Verification successful
--- The `re` module is indeed used in the file `custom_components/hacs/repositories/plugin.py`, specifically for compiling a regular expression pattern. - Line: `HACSTAG_REPLACER = re.compile(r"\D+")` This confirms that the import of the `re` module is necessary.Scripts executed
The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify usage of the `re` module in the file. # Test: Search for the usage of the `re` module. Expect: At least one usage. rg --type python 're\.' custom_components/hacs/repositories/plugin.py ``` Length of output: 102 --- --- Script: ```shell #!/bin/bash # Description: Verify usage of the `re` module in the file. # Test: Search for the usage of the `re` module. Expect: At least one usage. rg --type py 're\.' custom_components/hacs/repositories/plugin.py ``` Length of output: 291tests/repositories/test_plugin_repository.py (6)
`13-22`: The fixture `downloaded_plugin_repository` is correctly set up to provide a `HacsPluginRepository` instance for testing. --- `33-41`: The test `test_dashboard_namespace` correctly asserts the generation of namespaces for different repositories. --- `53-69`: The test `test_dashboard_hacstag` effectively checks the generation of HACS tags under various conditions. --- `72-77`: The test `test_dashboard_url` ensures that the URL generation for dashboard resources is correct. --- `80-88`: The series of tests from `test_get_resource_handler` to `test_get_resource_handler_no_hass_data` comprehensively cover various failure modes of the resource handler. These tests are crucial for ensuring robust error handling. Also applies to: 90-99, 102-111, 114-123, 126-135, 138-147, 150-159, 162-174 --- `176-197`: The tests `test_remove_dashboard_resource`, `test_add_dashboard_resource`, and `test_update_dashboard_resource` validate the functionality of adding, removing, and updating dashboard resources. These tests are well-structured and provide good coverage of the new functionalities. Also applies to: 199-217, 218-247
Implement handling of dashboard resources in the backend.
Previously, the UI did this, but now that the updates are served by entities, this is no longer the case.