Dispatcharr/tests/test_process_label.py
SergeantPanda c1ff5e35aa feat(process_label): add process role labeling for PostgreSQL connections
- Introduced a new module to determine the process role based on command-line arguments, enhancing PostgreSQL connection labeling for better monitoring.
- Updated the database connection parameters to include the application name derived from the process role.
- Added unit tests to validate the process role detection logic for different scenarios, including Celery and uWSGI.
2026-06-16 11:26:12 -05:00

18 lines
602 B
Python

from unittest.mock import patch
from django.test import SimpleTestCase
from dispatcharr.db.process_label import get_process_role
class ProcessLabelTests(SimpleTestCase):
def test_celery_worker_not_labeled_as_uwsgi(self):
role = get_process_role(
["/dispatcharrpy/bin/celery", "-A", "dispatcharr", "worker"]
)
self.assertEqual(role, "celery-worker")
def test_uwsgi_labeled_when_gevent_support(self):
with patch.dict("os.environ", {"GEVENT_SUPPORT": "True"}):
role = get_process_role(["uwsgi"])
self.assertEqual(role, "uwsgi")