-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for update_downloaded_repositories
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# pylint: disable=missing-function-docstring,missing-module-docstring, protected-access | ||
import pytest | ||
|
||
from custom_components.hacs.base import HacsBase | ||
from custom_components.hacs.enums import HacsCategory | ||
from custom_components.hacs.repositories.base import HacsRepository | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_update_downloaded_repositories(hacs: HacsBase, repository: HacsRepository): | ||
await hacs.tasks.async_load() | ||
task = hacs.tasks.get("update_downloaded_repositories") | ||
|
||
repository.data.category = HacsCategory.INTEGRATION | ||
repository.data.installed = True | ||
hacs.repositories.register(repository) | ||
|
||
hacs.enable_hacs_category(HacsCategory.INTEGRATION) | ||
|
||
assert task | ||
|
||
assert hacs.queue.pending_tasks == 0 | ||
await task.execute_task() | ||
assert hacs.queue.pending_tasks == 1 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_update_downloaded_repositories_skip_hacs_on_startup( | ||
hacs: HacsBase, | ||
repository: HacsRepository, | ||
): | ||
await hacs.tasks.async_load() | ||
task = hacs.tasks.get("update_downloaded_repositories") | ||
|
||
repository.data.category = HacsCategory.INTEGRATION | ||
repository.data.installed = True | ||
repository.data.full_name = "hacs/integration" | ||
hacs.repositories.register(repository) | ||
|
||
hacs.enable_hacs_category(HacsCategory.INTEGRATION) | ||
|
||
assert task | ||
|
||
assert hacs.queue.pending_tasks == 0 | ||
await task.execute_task() | ||
assert hacs.queue.pending_tasks == 0 |