From 3d2426e7b47f972adb9b8fadd43c16a456259d6c Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sat, 10 Dec 2016 11:55:49 -0800 Subject: [PATCH] Fix root_path in runserver tests --- channels/tests/test_management.py | 64 +++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/channels/tests/test_management.py b/channels/tests/test_management.py index 6213caa..54eaaef 100644 --- a/channels/tests/test_management.py +++ b/channels/tests/test_management.py @@ -85,9 +85,16 @@ class RunServerTests(TestCase): # See: # https://github.com/django/django/blob/master/django/core/management/commands/runserver.py#L105 call_command('runserver', '--noreload') - mocked_server.assert_called_with(port=8000, signal_handlers=True, http_timeout=60, - host='127.0.0.1', action_logger=mock.ANY, channel_layer=mock.ANY, - ws_protocols=None, root_path=None) + mocked_server.assert_called_with( + port=8000, + signal_handlers=True, + http_timeout=60, + host='127.0.0.1', + action_logger=mock.ANY, + channel_layer=mock.ANY, + ws_protocols=None, + root_path='', + ) @mock.patch('channels.management.commands.runserver.sys.stdout', new_callable=StringIO) @mock.patch('channels.management.commands.runserver.Server') @@ -99,17 +106,33 @@ class RunServerTests(TestCase): # Debug requires the static url is set. with self.settings(DEBUG=True, STATIC_URL='/static/'): call_command('runserver', '--noreload') - mocked_server.assert_called_with(port=8000, signal_handlers=True, http_timeout=60, - host='127.0.0.1', action_logger=mock.ANY, channel_layer=mock.ANY, - ws_protocols=None, root_path=None) + mocked_server.assert_called_with( + port=8000, + signal_handlers=True, + http_timeout=60, + host='127.0.0.1', + action_logger=mock.ANY, + channel_layer=mock.ANY, + ws_protocols=None, + root_path='', + ) call_command('runserver', '--noreload', 'localhost:8001') - mocked_server.assert_called_with(port=8001, signal_handlers=True, http_timeout=60, - host='localhost', action_logger=mock.ANY, channel_layer=mock.ANY, - ws_protocols=None, root_path=None) + mocked_server.assert_called_with( + port=8001, + signal_handlers=True, + http_timeout=60, + host='localhost', + action_logger=mock.ANY, + channel_layer=mock.ANY, + ws_protocols=None, + root_path='', + ) - self.assertFalse(mocked_worker.called, - "The worker should not be called with '--noworker'") + self.assertFalse( + mocked_worker.called, + "The worker should not be called with '--noworker'", + ) @mock.patch('channels.management.commands.runserver.sys.stdout', new_callable=StringIO) @mock.patch('channels.management.commands.runserver.Server') @@ -119,11 +142,20 @@ class RunServerTests(TestCase): Test that the Worker is not called when using the `--noworker` parameter. ''' call_command('runserver', '--noreload', '--noworker') - mocked_server.assert_called_with(port=8000, signal_handlers=True, http_timeout=60, - host='127.0.0.1', action_logger=mock.ANY, channel_layer=mock.ANY, - ws_protocols=None, root_path=None) - self.assertFalse(mocked_worker.called, - "The worker should not be called with '--noworker'") + mocked_server.assert_called_with( + port=8000, + signal_handlers=True, + http_timeout=60, + host='127.0.0.1', + action_logger=mock.ANY, + channel_layer=mock.ANY, + ws_protocols=None, + root_path='', + ) + self.assertFalse( + mocked_worker.called, + "The worker should not be called with '--noworker'", + ) @mock.patch('channels.management.commands.runserver.sys.stderr', new_callable=StringIO) def test_log_action(self, mocked_stderr):