From a283c95e2e8a3842e9e1117184662d2fcda21d27 Mon Sep 17 00:00:00 2001 From: Thomas LEVEIL Date: Fri, 27 Jan 2017 02:07:56 +0100 Subject: [PATCH] TESTS: nginxproxy fixture can provide the nginx generated conf in tests --- test2/conftest.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test2/conftest.py b/test2/conftest.py index 07b5f01..ccb123d 100644 --- a/test2/conftest.py +++ b/test2/conftest.py @@ -37,6 +37,18 @@ class requests_retry_on_error_502(object): if os.path.isfile(CA_ROOT_CERTIFICATE): self.session.verify = CA_ROOT_CERTIFICATE + def get_conf(self): + """ + Return the nginx config file + """ + docker_client = docker.from_env() + nginx_proxy_containers = docker_client.containers(filters={"ancestor": "jwilder/nginx-proxy:test"}) + if len(nginx_proxy_containers) > 1: + pytest.failed("Too many running jwilder/nginx-proxy:test containers") + elif len(nginx_proxy_containers) == 0: + pytest.failed("No running jwilder/nginx-proxy:test container") + return get_nginx_conf_from_container(nginx_proxy_containers[0]['Id']) + def get(self, *args, **kwargs): @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None) def _get(*args, **kwargs):