def __init__(self): from oonib.main.api import mainAPI from oonib.deck.api import deckAPI from oonib.report.api import reportAPI from oonib.input.api import inputAPI from oonib.policy.api import policyAPI from oonib.report.handlers import checkForStaleReports handlers = [] handlers += reportAPI if config.main.input_dir: handlers += inputAPI if config.main.deck_dir: handlers += deckAPI if config.main.policy_file: handlers += policyAPI handlers += mainAPI checkForStaleReports() web.Application.__init__(self, handlers, name='collector')
def __init__(self): from oonib.main.api import mainAPI from oonib.deck.api import deckAPI from oonib.report.api import reportAPI from oonib.input.api import inputAPI from oonib.policy.api import policyAPI from oonib.report.handlers import checkForStaleReports handlers = [] handlers += reportAPI if config.main.input_dir: handlers += inputAPI if config.main.deck_dir: handlers += deckAPI if config.main.policy_file: handlers += policyAPI handlers += mainAPI checkForStaleReports() web.Application.__init__(self, handlers, name='collector', log_function=log_function)
def test_create_update_reap(self): mock_time = MockTime() report_header = dummy_data.copy() report_header['format'] = 'json' response = yield self.request('/report', "POST", report_header) response_body = json.loads(response.body) self.assertIn('backend_version', response_body) self.assertIn('report_id', response_body) report_entry_count = 100 report_id = response_body['report_id'] for i in range(report_entry_count): yield self.update_report(report_id, content=sample_report_entry, format="json") mock_time.advance(config.main.stale_time + 1) delayed_call = checkForStaleReports(mock_time) delayed_call.cancel() written_report_path = report_file_path(FilePath("."), report_header, report_id) with written_report_path.open('r') as f: self.filenames.add(written_report_path.path) for line in f: written_report = json.loads(line) self.assertEqual(sample_report_entry, written_report)