def test_longer_timeout_allows_long_task_to_finish(self, app_longer_timeout): hades_logs = HadesLogs(app_longer_timeout) try: tasks = list(hades_logs.fetch_logs(nasipaddress='', nasportid='magic_sleep')) except HadesTimeout: pytest.fail("HadesTimeout triggered even with significantly longer timeout") else: assert tasks == []
class SimpleFlaskWithHadesLogsBase(DummyHadesWorkerBase): def setUp(self): super().setUp() self.app = Flask('test') self.app.config.update(self.hades_logs_config) self.hades_logs = HadesLogs(self.app) self.valid_kwargs = {'nasipaddress': '141.30.223.206', 'nasportid': 'C6'} def fetch_logs(self, *a, **kw): """Call :py:meth:`hades_logs.fetch_logs` and convert to list :rtype: list """ return list(self.hades_logs.fetch_logs(*a, **kw))
class CorrectURIsConfiguredTestCase(TestCase): """Provides ``HadesLogs`` with syntactically correct URIs""" def setUp(self): super().setUp() self.app = Flask('test') self.app.config.update({ 'HADES_CELERY_APP_NAME': 'test', 'HADES_BROKER_URI': 'amqp://localhost:5762/', 'HADES_RESULT_BACKEND_URI': 'rpc://localhost:5762/', }) self.hades_logs = HadesLogs(self.app) def test_empty_task_raises_operational_error(self): # This throws an OSError as there is no `HadesLogs` around to # catch it. with self.assertRaises(OSError): self.hades_logs.celery.signature('').apply_async().wait() def test_fetch_logs_logs_and_raises_connection_refused(self): with self.assertRaises(HadesOperationalError), \ self.assertLogs('hades_logs', level=logging.INFO) as cm: self.hades_logs.fetch_logs(None, None) self.assertEqual(len(cm.output), 1) self.assertIn("waiting for task", cm.output.pop().lower())
class SimpleFlaskWithHadesLogsBase(DummyHadesWorkerBase): def setUp(self): super().setUp() self.app = Flask('test') self.app.config.update(self.hades_logs_config) self.hades_logs = HadesLogs(self.app) self.valid_kwargs = { 'nasipaddress': '141.30.223.206', 'nasportid': 'C6' } def fetch_logs(self, *a, **kw): """Call :py:meth:`hades_logs.fetch_logs` and convert to list :rtype: list """ return list(self.hades_logs.fetch_logs(*a, **kw))