2023-03-12 16:54:50 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from tests.markers import requires_docker
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
@requires_docker
|
2023-10-23 21:42:34 +00:00
|
|
|
@pytest.mark.order(0)
|
2023-12-14 21:35:36 +00:00
|
|
|
def test_docker_package_is_available() -> None:
|
2023-03-12 16:54:50 +00:00
|
|
|
try:
|
|
|
|
import docker # noqa: F401 # pylint: disable=unused-import
|
|
|
|
except ImportError as err:
|
|
|
|
logger.error("error running docker: %s", err)
|
|
|
|
assert False, (
|
|
|
|
"Docker package cannot be imported. "
|
|
|
|
+ f"This causes various tests to fail. Err: {err}"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@requires_docker
|
2023-10-23 21:42:34 +00:00
|
|
|
@pytest.mark.order(0)
|
2023-12-14 21:35:36 +00:00
|
|
|
def test_docker_is_running_and_available() -> None:
|
2023-03-12 16:54:50 +00:00
|
|
|
import docker
|
|
|
|
from docker.errors import DockerException
|
|
|
|
|
|
|
|
try:
|
|
|
|
docker.from_env()
|
|
|
|
except DockerException as err:
|
|
|
|
logger.error("error running docker: %s", err)
|
|
|
|
assert False, (
|
|
|
|
"Docker seems not to be running. "
|
|
|
|
+ f"This causes various tests to fail. Err: {err}"
|
|
|
|
)
|