示例#1
0
def docker() -> DockerAPI:
    """Mock DockerAPI."""
    images = [MagicMock(tags=["homeassistant/amd64-hassio-supervisor:latest"])]

    with patch("docker.DockerClient",
               return_value=MagicMock()), patch(
                   "supervisor.docker.DockerAPI.images",
                   return_value=MagicMock()), patch(
                       "supervisor.docker.DockerAPI.containers",
                       return_value=MagicMock()), patch(
                           "supervisor.docker.DockerAPI.api",
                           return_value=MagicMock()), patch(
                               "supervisor.docker.DockerAPI.images.list",
                               return_value=images), patch(
                                   "supervisor.docker.DockerAPI.info",
                                   return_value=MagicMock(),
                               ), patch(
                                   "supervisor.docker.DockerConfig",
                                   return_value=MagicMock(),
                               ):
        docker_obj = DockerAPI()
        docker_obj.info.logging = "journald"
        docker_obj.info.storage = "overlay2"
        docker_obj.info.version = "1.0.0"

        docker_obj.config.registries = {}

        yield docker_obj
示例#2
0
def docker() -> DockerAPI:
    """Mock DockerAPI."""
    images = [MagicMock(tags=["homeassistant/amd64-hassio-supervisor:latest"])]

    with patch("docker.DockerClient", return_value=MagicMock()), patch(
        "supervisor.docker.DockerAPI.images", return_value=MagicMock()
    ), patch("supervisor.docker.DockerAPI.containers", return_value=MagicMock()), patch(
        "supervisor.docker.DockerAPI.api", return_value=MagicMock()
    ), patch(
        "supervisor.docker.DockerAPI.images.list", return_value=images
    ):
        docker_obj = DockerAPI()

        yield docker_obj