Fix root_path in runserver tests

This commit is contained in:
Andrew Godwin 2016-12-10 11:55:49 -08:00
parent 5a38171fc7
commit 3d2426e7b4

View File

@ -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):