| 1 |
import pytest |
| 2 |
import importlib.resources |
| 3 |
|
| 4 |
# Load gunicorn configuration |
| 5 |
def load_gunicorn_config(): |
| 6 |
gunicorn_config = {} |
| 7 |
a2d_files = importlib.resources.files('a2d') |
| 8 |
config_path = a2d_files / 'gunicorn_config.py' |
| 9 |
|
| 10 |
with config_path.open() as f: |
| 11 |
exec(f.read(), gunicorn_config) |
| 12 |
|
| 13 |
return gunicorn_config |
| 14 |
|
| 15 |
# Test for checking if gunicorn.conf.py exists |
| 16 |
def test_config_file_exists(): |
| 17 |
a2d_files = importlib.resources.files('a2d') |
| 18 |
config_path = a2d_files / 'gunicorn_config.py' |
| 19 |
assert config_path.exists(), "gunicorn.conf.py file does not exist" |
| 20 |
|
| 21 |
# Parameterized test for each configuration key |
| 22 |
@pytest.mark.parametrize('key', [ |
| 23 |
'bind', |
| 24 |
'workers', |
| 25 |
'threads', |
| 26 |
'max_requests', |
| 27 |
'max_requests_jitter', |
| 28 |
'timeout', |
| 29 |
'errorlog', |
| 30 |
'loglevel', |
| 31 |
'logrotate' |
| 32 |
]) |
| 33 |
def test_gunicorn_config_keys(key): |
| 34 |
gunicorn_config = load_gunicorn_config() |
| 35 |
assert key in gunicorn_config, f"Key '{key}' not found in gunicorn config" |