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 requests import Response
|
||||||
from urllib3.util.connection import HAS_IPV6
|
from urllib3.util.connection import HAS_IPV6
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
logging.getLogger('backoff').setLevel(logging.INFO)
|
logging.getLogger('backoff').setLevel(logging.INFO)
|
||||||
logging.getLogger('DNS').setLevel(logging.DEBUG)
|
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}")
|
logging.debug(f"using docker compose files {compose_files}")
|
||||||
return compose_files
|
return compose_files
|
||||||
|
|
||||||
|
|
||||||
def connect_to_network(network: Network) -> Optional[Network]:
|
def connect_to_network(network: Network) -> Optional[Network]:
|
||||||
"""
|
"""
|
||||||
If we are running from a container, connect our container to the given network
|
If we are running from a container, connect our container to the given network
|
||||||
@ -513,8 +515,8 @@ def docker_composer() -> Iterator[DockerComposer]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def ca_root_certificate() -> Iterator[str]:
|
def ca_root_certificate() -> str:
|
||||||
yield CA_ROOT_CERTIFICATE
|
return CA_ROOT_CERTIFICATE.as_posix()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -569,11 +571,11 @@ def nginxproxy() -> Iterator[RequestsForDocker]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@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
|
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 pathlib
|
||||||
import re
|
import re
|
||||||
from typing import List
|
from typing import List, Callable
|
||||||
|
|
||||||
import backoff
|
import backoff
|
||||||
import pytest
|
import pytest
|
||||||
import requests
|
import requests
|
||||||
|
from requests import Response
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -17,21 +18,15 @@ def docker_compose_files(compose_file) -> List[str]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def docker_compose_file(data_dir, compose_file):
|
def get(docker_compose, nginxproxy, want_err_re: re.Pattern[str]) -> Callable[[str], Response]:
|
||||||
return os.path.join(data_dir, compose_file)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def get(docker_compose, nginxproxy, want_err_re):
|
|
||||||
|
|
||||||
@backoff.on_exception(
|
@backoff.on_exception(
|
||||||
backoff.constant,
|
backoff.constant,
|
||||||
requests.exceptions.SSLError,
|
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,
|
interval=.3,
|
||||||
max_tries=30,
|
max_tries=30,
|
||||||
jitter=None)
|
jitter=None)
|
||||||
def _get(url):
|
def _get(url) -> Response:
|
||||||
return nginxproxy.get(url, allow_redirects=False)
|
return nginxproxy.get(url, allow_redirects=False)
|
||||||
|
|
||||||
return _get
|
return _get
|
||||||
|
Loading…
x
Reference in New Issue
Block a user