mirror of
				https://github.com/django/daphne.git
				synced 2025-11-04 09:37:32 +03:00 
			
		
		
		
	Make formatting in management tests consistent
This commit is contained in:
		
							parent
							
								
									3d2426e7b4
								
							
						
					
					
						commit
						54705915de
					
				| 
						 | 
					@ -41,7 +41,11 @@ class RunWorkerTests(TestCase):
 | 
				
			||||||
            # Use 'fake_channel' that bypasses the 'inmemory' check
 | 
					            # Use 'fake_channel' that bypasses the 'inmemory' check
 | 
				
			||||||
            call_command('runworker', '--layer', 'fake_channel')
 | 
					            call_command('runworker', '--layer', 'fake_channel')
 | 
				
			||||||
            mock_worker.assert_called_with(
 | 
					            mock_worker.assert_called_with(
 | 
				
			||||||
                only_channels=None, exclude_channels=None, callback=None, channel_layer=mock.ANY)
 | 
					                only_channels=None,
 | 
				
			||||||
 | 
					                exclude_channels=None,
 | 
				
			||||||
 | 
					                callback=None,
 | 
				
			||||||
 | 
					                channel_layer=mock.ANY,
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            channel_layer = mock_worker.call_args[1]['channel_layer']
 | 
					            channel_layer = mock_worker.call_args[1]['channel_layer']
 | 
				
			||||||
            static_consumer = channel_layer.router.root.routing[0].consumer
 | 
					            static_consumer = channel_layer.router.root.routing[0].consumer
 | 
				
			||||||
| 
						 | 
					@ -50,21 +54,24 @@ class RunWorkerTests(TestCase):
 | 
				
			||||||
    def test_runworker(self, mock_worker):
 | 
					    def test_runworker(self, mock_worker):
 | 
				
			||||||
        # Use 'fake_channel' that bypasses the 'inmemory' check
 | 
					        # Use 'fake_channel' that bypasses the 'inmemory' check
 | 
				
			||||||
        call_command('runworker', '--layer', 'fake_channel')
 | 
					        call_command('runworker', '--layer', 'fake_channel')
 | 
				
			||||||
        mock_worker.assert_called_with(callback=None,
 | 
					        mock_worker.assert_called_with(
 | 
				
			||||||
 | 
					            callback=None,
 | 
				
			||||||
            only_channels=None,
 | 
					            only_channels=None,
 | 
				
			||||||
            channel_layer=mock.ANY,
 | 
					            channel_layer=mock.ANY,
 | 
				
			||||||
                                       exclude_channels=None)
 | 
					            exclude_channels=None,
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_runworker_verbose(self, mocked_worker):
 | 
					    def test_runworker_verbose(self, mocked_worker):
 | 
				
			||||||
        # Use 'fake_channel' that bypasses the 'inmemory' check
 | 
					        # Use 'fake_channel' that bypasses the 'inmemory' check
 | 
				
			||||||
        call_command('runworker', '--layer',
 | 
					        call_command('runworker', '--layer', 'fake_channel', '--verbosity', '2')
 | 
				
			||||||
                     'fake_channel', '--verbosity', '2')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Verify the callback is set
 | 
					        # Verify the callback is set
 | 
				
			||||||
        mocked_worker.assert_called_with(callback=mock.ANY,
 | 
					        mocked_worker.assert_called_with(
 | 
				
			||||||
 | 
					            callback=mock.ANY,
 | 
				
			||||||
            only_channels=None,
 | 
					            only_channels=None,
 | 
				
			||||||
            channel_layer=mock.ANY,
 | 
					            channel_layer=mock.ANY,
 | 
				
			||||||
                                         exclude_channels=None)
 | 
					            exclude_channels=None,
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class RunServerTests(TestCase):
 | 
					class RunServerTests(TestCase):
 | 
				
			||||||
| 
						 | 
					@ -161,33 +168,26 @@ class RunServerTests(TestCase):
 | 
				
			||||||
    def test_log_action(self, mocked_stderr):
 | 
					    def test_log_action(self, mocked_stderr):
 | 
				
			||||||
        cmd = runserver.Command()
 | 
					        cmd = runserver.Command()
 | 
				
			||||||
        test_actions = [
 | 
					        test_actions = [
 | 
				
			||||||
            (100, 'http', 'complete',
 | 
					            (100, 'http', 'complete', 'HTTP GET /a-path/ 100 [0.12, a-client]'),
 | 
				
			||||||
             'HTTP GET /a-path/ 100 [0.12, a-client]'),
 | 
					            (200, 'http', 'complete', 'HTTP GET /a-path/ 200 [0.12, a-client]'),
 | 
				
			||||||
            (200, 'http', 'complete',
 | 
					            (300, 'http', 'complete', 'HTTP GET /a-path/ 300 [0.12, a-client]'),
 | 
				
			||||||
             'HTTP GET /a-path/ 200 [0.12, a-client]'),
 | 
					            (304, 'http', 'complete', 'HTTP GET /a-path/ 304 [0.12, a-client]'),
 | 
				
			||||||
            (300, 'http', 'complete',
 | 
					            (400, 'http', 'complete', 'HTTP GET /a-path/ 400 [0.12, a-client]'),
 | 
				
			||||||
             'HTTP GET /a-path/ 300 [0.12, a-client]'),
 | 
					            (404, 'http', 'complete', 'HTTP GET /a-path/ 404 [0.12, a-client]'),
 | 
				
			||||||
            (304, 'http', 'complete',
 | 
					            (500, 'http', 'complete', 'HTTP GET /a-path/ 500 [0.12, a-client]'),
 | 
				
			||||||
             'HTTP GET /a-path/ 304 [0.12, a-client]'),
 | 
					            (None, 'websocket', 'connected', 'WebSocket CONNECT /a-path/ [a-client]'),
 | 
				
			||||||
            (400, 'http', 'complete',
 | 
					            (None, 'websocket', 'disconnected', 'WebSocket DISCONNECT /a-path/ [a-client]'),
 | 
				
			||||||
             'HTTP GET /a-path/ 400 [0.12, a-client]'),
 | 
					 | 
				
			||||||
            (404, 'http', 'complete',
 | 
					 | 
				
			||||||
             'HTTP GET /a-path/ 404 [0.12, a-client]'),
 | 
					 | 
				
			||||||
            (500, 'http', 'complete',
 | 
					 | 
				
			||||||
             'HTTP GET /a-path/ 500 [0.12, a-client]'),
 | 
					 | 
				
			||||||
            (None, 'websocket', 'connected',
 | 
					 | 
				
			||||||
             'WebSocket CONNECT /a-path/ [a-client]'),
 | 
					 | 
				
			||||||
            (None, 'websocket', 'disconnected',
 | 
					 | 
				
			||||||
             'WebSocket DISCONNECT /a-path/ [a-client]'),
 | 
					 | 
				
			||||||
            (None, 'websocket', 'something', ''),  # This shouldn't happen
 | 
					            (None, 'websocket', 'something', ''),  # This shouldn't happen
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for status_code, protocol, action, output in test_actions:
 | 
					        for status_code, protocol, action, output in test_actions:
 | 
				
			||||||
            details = {'status': status_code,
 | 
					            details = {
 | 
				
			||||||
 | 
					                'status': status_code,
 | 
				
			||||||
                'method': 'GET',
 | 
					                'method': 'GET',
 | 
				
			||||||
                'path': '/a-path/',
 | 
					                'path': '/a-path/',
 | 
				
			||||||
                'time_taken': 0.12345,
 | 
					                'time_taken': 0.12345,
 | 
				
			||||||
                       'client': 'a-client'}
 | 
					                'client': 'a-client',
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            cmd.log_action(protocol, action, details)
 | 
					            cmd.log_action(protocol, action, details)
 | 
				
			||||||
            self.assertIn(output, mocked_stderr.getvalue())
 | 
					            self.assertIn(output, mocked_stderr.getvalue())
 | 
				
			||||||
            # Clear previous output
 | 
					            # Clear previous output
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user