mirror of
https://github.com/django/daphne.git
synced 2025-07-25 14:39:46 +03:00
Added tests for multi-worker functionality on the server and correct interpretation of the --workers argument in the CLI.
This commit is contained in:
parent
663cf4a23d
commit
0a56c37834
|
@ -282,3 +282,14 @@ class DaphneTestCase(unittest.TestCase):
|
|||
self.assertIsInstance(address, str)
|
||||
self.assert_is_ip_address(address)
|
||||
self.assertIsInstance(port, int)
|
||||
|
||||
def test_multiple_workers(self):
|
||||
"""
|
||||
Tests that the server can start with multiple workers.
|
||||
"""
|
||||
with DaphneTestingInstance() as test_app:
|
||||
# Configure the server with 3 workers
|
||||
test_app.process.kwargs["workers"] = 3
|
||||
test_app.process.start()
|
||||
# Verify that the server is running
|
||||
self.assertTrue(test_app.process.ready.wait(test_app.startup_timeout))
|
||||
|
|
|
@ -257,6 +257,18 @@ class TestCLIInterface(TestCase):
|
|||
"""
|
||||
self.assertCLI(["--no-server-name"], {"server_name": ""})
|
||||
|
||||
def test_workers_default(self):
|
||||
"""
|
||||
Tests that the default number of workers is 1.
|
||||
"""
|
||||
self.assertCLI([], {"workers": 1})
|
||||
|
||||
def test_workers_custom(self):
|
||||
"""
|
||||
Tests that the CLI correctly parses the --workers argument.
|
||||
"""
|
||||
self.assertCLI(["--workers", "4"], {"workers": 4})
|
||||
|
||||
|
||||
@skipUnless(os.getenv("ASGI_THREADS"), "ASGI_THREADS environment variable not set.")
|
||||
class TestASGIThreads(TestCase):
|
||||
|
|
Loading…
Reference in New Issue
Block a user