mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 01:38:15 +00:00
tests: type hints and linting
This commit is contained in:
parent
40309e2441
commit
bfdd72fe95
@ -23,6 +23,7 @@ from packaging.version import Version
|
||||
from requests import Response
|
||||
from urllib3.util.connection import HAS_IPV6
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logging.getLogger('backoff').setLevel(logging.INFO)
|
||||
logging.getLogger('DNS').setLevel(logging.DEBUG)
|
||||
@ -403,6 +404,7 @@ def docker_compose_files(request: FixtureRequest) -> List[str]:
|
||||
logging.debug(f"using docker compose files {compose_files}")
|
||||
return compose_files
|
||||
|
||||
|
||||
def connect_to_network(network: Network) -> Optional[Network]:
|
||||
"""
|
||||
If we are running from a container, connect our container to the given network
|
||||
@ -507,14 +509,14 @@ class DockerComposer(contextlib.AbstractContextManager):
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def docker_composer() -> Iterator[DockerComposer]:
|
||||
def docker_composer() -> Iterator[DockerComposer]:
|
||||
with DockerComposer() as d:
|
||||
yield d
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ca_root_certificate() -> Iterator[str]:
|
||||
yield CA_ROOT_CERTIFICATE
|
||||
def ca_root_certificate() -> str:
|
||||
return CA_ROOT_CERTIFICATE.as_posix()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -569,11 +571,11 @@ def nginxproxy() -> Iterator[RequestsForDocker]:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def acme_challenge_path() -> Iterator[str]:
|
||||
def acme_challenge_path() -> str:
|
||||
"""
|
||||
Provides fake Let's Encrypt ACME challenge path used in certain tests
|
||||
"""
|
||||
yield ".well-known/acme-challenge/test-filename"
|
||||
return ".well-known/acme-challenge/test-filename"
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
|
@ -1,10 +1,11 @@
|
||||
import pathlib
|
||||
import re
|
||||
from typing import List
|
||||
from typing import List, Callable
|
||||
|
||||
import backoff
|
||||
import pytest
|
||||
import requests
|
||||
from requests import Response
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -17,21 +18,15 @@ def docker_compose_files(compose_file) -> List[str]:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def docker_compose_file(data_dir, compose_file):
|
||||
return os.path.join(data_dir, compose_file)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def get(docker_compose, nginxproxy, want_err_re):
|
||||
|
||||
def get(docker_compose, nginxproxy, want_err_re: re.Pattern[str]) -> Callable[[str], Response]:
|
||||
@backoff.on_exception(
|
||||
backoff.constant,
|
||||
requests.exceptions.SSLError,
|
||||
giveup=lambda e: want_err_re and want_err_re.search(str(e)),
|
||||
giveup=lambda e: want_err_re and bool(want_err_re.search(str(e))),
|
||||
interval=.3,
|
||||
max_tries=30,
|
||||
jitter=None)
|
||||
def _get(url):
|
||||
def _get(url) -> Response:
|
||||
return nginxproxy.get(url, allow_redirects=False)
|
||||
|
||||
return _get
|
||||
|
Loading…
x
Reference in New Issue
Block a user