-
-
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.
* Init proxy tests * lint
- Loading branch information
Showing
7 changed files
with
124 additions
and
6 deletions.
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
1 change: 1 addition & 0 deletions
1
tests/fixtures/proxy/raw.githubusercontent.com/octocat/integration/1.0.0/README.md
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 @@ | ||
## Example readme file (1.0.0) |
3 changes: 3 additions & 0 deletions
3
tests/fixtures/proxy/raw.githubusercontent.com/octocat/integration/1.0.0/hacs.json
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,3 @@ | ||
{ | ||
"name": "Proxy integration" | ||
} |
1 change: 1 addition & 0 deletions
1
tests/fixtures/proxy/raw.githubusercontent.com/octocat/integration/2.0.0/README.md
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 @@ | ||
## Example readme file (2.0.0) |
3 changes: 3 additions & 0 deletions
3
tests/fixtures/proxy/raw.githubusercontent.com/octocat/integration/2.0.0/hacs.json
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,3 @@ | ||
{ | ||
"name": "Proxy integration" | ||
} |
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,36 @@ | ||
from typing import Any | ||
|
||
import pytest | ||
|
||
from custom_components.hacs.base import HacsBase | ||
from custom_components.hacs.repositories.base import HacsRepository | ||
|
||
from tests.common import client_session_proxy | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"data,result", | ||
[ | ||
({"installed": True, "installed_version": "1.0.0"}, "Example readme file (1.0.0)"), | ||
( | ||
{"installed": True, "installed_version": "1.0.0", "last_version": "2.0.0"}, | ||
"Example readme file (1.0.0)", | ||
), | ||
({"installed": False, "last_version": "2.0.0"}, "Example readme file (2.0.0)"), | ||
({"installed": False, "last_version": "99.99.99"}, None), | ||
], | ||
) | ||
@pytest.mark.asyncio | ||
async def test_validate_repository(hacs: HacsBase, data: dict[str, Any], result: str | None): | ||
repository = HacsRepository(hacs=hacs) | ||
repository.data.full_name = "octocat/integration" | ||
for key, value in data.items(): | ||
setattr(repository.data, key, value) | ||
|
||
hacs.session = await client_session_proxy(hacs.hass) | ||
docs = await repository.get_documentation(filename="README.md") | ||
|
||
if result: | ||
assert result in docs | ||
else: | ||
assert result is None |
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,21 @@ | ||
import pytest | ||
|
||
from custom_components.hacs.base import HacsBase | ||
from custom_components.hacs.repositories.base import HacsRepository | ||
|
||
from tests.common import client_session_proxy | ||
|
||
|
||
@pytest.mark.parametrize("version,name", [("1.0.0", "Proxy integration"), ("99.99.99", None)]) | ||
@pytest.mark.asyncio | ||
async def test_validate_repository(hacs: HacsBase, version: str, name: str | None): | ||
repository = HacsRepository(hacs=hacs) | ||
repository.data.full_name = "octocat/integration" | ||
|
||
hacs.session = await client_session_proxy(hacs.hass) | ||
manifest = await repository.get_hacs_json(version=version) | ||
|
||
if name: | ||
assert manifest.name == name | ||
else: | ||
assert manifest is None |