Skip to content

Commit

Permalink
Reflect parent project
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklinke committed Oct 24, 2023
1 parent cd3d7fa commit 86e8316
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ omit = ["tests/*", "**/migrations/*", "**/__init__.py"]
[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "tests.settings"
python_files = ["*test_*.py", "*_test.py", "tests/*.py"]
log_cli = true
log_cli_level = "INFO"

[tool.isort]
profile = "black"
Expand Down
18 changes: 14 additions & 4 deletions tests/test_with_docker_compose_playwright.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This is a sample test for Playwright using Docker Compose."""
"""This is a sample test for the Django app with Playwright using Docker Compose."""
import logging
import re
import subprocess # nosec

import pytest
import requests
Expand All @@ -19,21 +20,30 @@ def is_responsive(url):
return False


def check_docker_ps():
"""Check if docker compose is running, and log the output using subprocess.Popen."""
cmd = ["docker", "ps"]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec
stdout, stderr = proc.communicate()
logging.info(f"check_docker_ps return code: {proc.returncode}\noutput: {stdout}\nerrors: {stderr}")


@pytest.fixture(scope="session")
def http_service(docker_ip, docker_services):
"""Ensure that HTTP service is up and responsive."""
port = docker_services.port_for("django_test", 8000)
url = f"http://{docker_ip}:{port}"
docker_services.wait_until_responsive(timeout=30.0, pause=0.1, check=lambda: is_responsive(url))
logging.info(f"http_service url: {url}")
check_docker_ps()
docker_services.wait_until_responsive(timeout=60.0, pause=0.1, check=lambda: is_responsive(url))

return url


def test_status_code(http_service):
"""Check the status code of the HTTP service."""
logging.info(f"http_service: {http_service}")
response = requests.get(http_service, timeout=60)
logging.info(f"response: {response}")
logging.info(f"test_status_code response: {response}")

assert response.status_code == 200

Expand Down

0 comments on commit 86e8316

Please sign in to comment.