mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-09 10:59:43 +00:00
Fix mypy issues in docker, hardware and homeassistant modules (#5805)
* Fix mypy issues in docker and hardware modules * Fix mypy issues in homeassistant module * Fix async_send_command typing * Fixes from feedback
This commit is contained in:
@@ -5,37 +5,44 @@ from supervisor.coresys import CoreSys
|
||||
from supervisor.docker.interface import DOCKER_HUB, DockerInterface
|
||||
|
||||
|
||||
def test_no_credentials(coresys: CoreSys):
|
||||
def test_no_credentials(coresys: CoreSys, test_docker_interface: DockerInterface):
|
||||
"""Test no credentials."""
|
||||
docker = DockerInterface(coresys)
|
||||
coresys.docker.config._data["registries"] = {
|
||||
DOCKER_HUB: {"username": "Spongebob Squarepants", "password": "Password1!"}
|
||||
}
|
||||
assert not docker._get_credentials("ghcr.io/homeassistant")
|
||||
assert not docker._get_credentials("ghcr.io/homeassistant/amd64-supervisor")
|
||||
assert not test_docker_interface._get_credentials("ghcr.io/homeassistant")
|
||||
assert not test_docker_interface._get_credentials(
|
||||
"ghcr.io/homeassistant/amd64-supervisor"
|
||||
)
|
||||
|
||||
|
||||
def test_no_matching_credentials(coresys: CoreSys):
|
||||
def test_no_matching_credentials(
|
||||
coresys: CoreSys, test_docker_interface: DockerInterface
|
||||
):
|
||||
"""Test no matching credentials."""
|
||||
docker = DockerInterface(coresys)
|
||||
coresys.docker.config._data["registries"] = {
|
||||
DOCKER_HUB: {"username": "Spongebob Squarepants", "password": "Password1!"}
|
||||
}
|
||||
assert not docker._get_credentials("ghcr.io/homeassistant")
|
||||
assert not docker._get_credentials("ghcr.io/homeassistant/amd64-supervisor")
|
||||
assert not test_docker_interface._get_credentials("ghcr.io/homeassistant")
|
||||
assert not test_docker_interface._get_credentials(
|
||||
"ghcr.io/homeassistant/amd64-supervisor"
|
||||
)
|
||||
|
||||
|
||||
def test_matching_credentials(coresys: CoreSys):
|
||||
def test_matching_credentials(coresys: CoreSys, test_docker_interface: DockerInterface):
|
||||
"""Test no matching credentials."""
|
||||
docker = DockerInterface(coresys)
|
||||
coresys.docker.config._data["registries"] = {
|
||||
"ghcr.io": {"username": "Octocat", "password": "Password1!"},
|
||||
DOCKER_HUB: {"username": "Spongebob Squarepants", "password": "Password1!"},
|
||||
}
|
||||
|
||||
credentials = docker._get_credentials("ghcr.io/homeassistant/amd64-supervisor")
|
||||
credentials = test_docker_interface._get_credentials(
|
||||
"ghcr.io/homeassistant/amd64-supervisor"
|
||||
)
|
||||
assert credentials["registry"] == "ghcr.io"
|
||||
|
||||
credentials = docker._get_credentials("homeassistant/amd64-supervisor")
|
||||
credentials = test_docker_interface._get_credentials(
|
||||
"homeassistant/amd64-supervisor"
|
||||
)
|
||||
assert credentials["username"] == "Spongebob Squarepants"
|
||||
assert "registry" not in credentials
|
||||
|
||||
Reference in New Issue
Block a user