async def test_adapter_bad_timeout(self, async_proxy_adapter_test, caplog): """Test that a bad timeout specified for the proxy adatper yields a logged error message.""" bad_timeout = 'not_timeout' _ = await AsyncProxyAdapter(request_timeout=bad_timeout) assert log_message_seen(caplog, logging.ERROR, 'Illegal timeout specified for proxy adapter: {}'.format(bad_timeout))
def test_server_missing_adapters(self, no_adapter_server, caplog): """Test that a server with no adapters loaded generates a warning message.""" assert log_message_seen( caplog, logging.WARNING, 'Failed to resolve API adapters: No adapters specified in configuration', when="setup")
def test_num_processes_change(self, test_system_status, caplog): """Test that monitoring processes correctly detects a change in the number of processes.""" test_system_status.stash_method = test_system_status.system_status.find_processes test_system_status.stash_processes = dict( test_system_status.system_status._processes) test_system_status.system_status._processes = {} test_system_status.system_status._processes['python'] = \ test_system_status.stash_processes['python'] current_processes = test_system_status.system_status.find_processes( 'python') patched_processes = list(current_processes) patched_processes.append(current_processes[0]) test_system_status.system_status.find_processes = Mock( return_value=patched_processes) logging.getLogger().setLevel(logging.DEBUG) test_system_status.system_status.monitor_processes() # monitor_process will detect change in number of processes and log a debug message assert log_message_seen(caplog, logging.DEBUG, "Number of processes named python is now") test_system_status.system_status.find_processes = test_system_status.stash_method test_system_status.system_status._processes = test_system_status.stash_processes
def test_bad_access_log_level(self, caplog): """Test that a bad access logging level generates an error.""" bad_level = 'wibble' http_server = HttpServer(adapters=[], access_logging=bad_level) assert log_message_seen( caplog, logging.ERROR, 'Access logging level {} not recognised'.format(bad_level))
def test_default_route_bad_path(self, caplog): """Test DefaultRoute logs warning about bad path to static content.""" path = '../missing_path' def_route = DefaultRoute(path) assert path in def_route.default_handler_args['path'] assert log_message_seen(caplog, logging.WARNING, 'Default handler static path does not exist')
def test_adapter_no_target_spec(self, caplog): """ Test that a proxy adapter instantiated with no target specifier yields a logged error message. """ _ = ProxyAdapter() assert log_message_seen(caplog, logging.ERROR, "Failed to resolve targets for proxy adapter")
async def test_adapter_bad_target_spec(self, caplog): """ Test that an incorrectly formatted target specified passed to a proxy adapter yields a logged error message. """ bad_target_spec = 'bad_target_1,bad_target_2' _ = await AsyncProxyAdapter(targets=bad_target_spec) assert log_message_seen(caplog, logging.ERROR, "Illegal target specification for proxy adapter: bad_target_1")
def test_num_processes_change(self, test_system_status, caplog): """Test that monitoring processes correctly detects a change in the number of processes.""" # Ensure that the process monitoring has run once test_system_status.system_status.monitor_processes() # Reduce the number of processes to find and monitor again - test_system_status.num_mocked_procs -= 1 logging.getLogger().setLevel(logging.DEBUG) test_system_status.system_status.monitor_processes() # monitor_process will detect change in number of processes and log a debug message assert log_message_seen(caplog, logging.DEBUG, "Number of processes named mock_proc is now")