mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-18 00:55:50 +00:00
enhancement(tests): introduce isolated backend test settings and improve test documentation
- Added `dispatcharr.settings_test` for isolated testing, automatically creating an empty PostgreSQL test database and ensuring transaction isolation during tests. - Updated `manage.py` to switch to the test settings when running tests. - Enhanced the CONTRIBUTING.md file with detailed instructions on running the backend test suite and handling Celery tasks in tests. - Refactored test cases to use static methods for `worker_id` in `test_process_label.py` and adjusted assertions in `test_user_preferences.py` for better clarity and correctness.
This commit is contained in:
parent
7b6adf62d7
commit
53fa1e42a0
6 changed files with 85 additions and 6 deletions
|
|
@ -17,13 +17,13 @@ class ProcessLabelTests(SimpleTestCase):
|
|||
self.assertEqual(role, "uwsgi")
|
||||
|
||||
def test_uwsgi_labeled_when_worker_module_present(self):
|
||||
fake_uwsgi = type("uwsgi", (), {"worker_id": lambda: 2})()
|
||||
fake_uwsgi = type("uwsgi", (), {"worker_id": staticmethod(lambda: 2)})()
|
||||
with patch.dict("sys.modules", {"uwsgi": fake_uwsgi}):
|
||||
role = get_process_role(["/dispatcharrpy/bin/python", "-c", "pass"])
|
||||
self.assertEqual(role, "uwsgi")
|
||||
|
||||
def test_uwsgi_master_not_labeled_as_uwsgi(self):
|
||||
fake_uwsgi = type("uwsgi", (), {"worker_id": lambda: 0})()
|
||||
fake_uwsgi = type("uwsgi", (), {"worker_id": staticmethod(lambda: 0)})()
|
||||
with patch.dict("sys.modules", {"uwsgi": fake_uwsgi}):
|
||||
role = get_process_role(["/dispatcharrpy/bin/python", "-c", "pass"])
|
||||
self.assertEqual(role, "django")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue