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)
def test_create_update_and_close_report_json(self): 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") response = yield self.request('/report/%s/close' % report_id, "POST") 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)
def test_create_update_and_close_report(self): response = yield self.request('/report', "POST", dummy_data) 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) with open(report_id) as f: written_report = yaml.safe_load_all(f) written_report_header = written_report.next() for key in dummy_data.keys(): self.assertEqual(written_report_header[key], dummy_data[key]) self.assertEqual(yaml.safe_load(sample_report_entry_yaml), written_report.next()) response = yield self.request('/report/%s/close' % report_id, "POST") written_report_header['format'] = 'yaml' written_report_path = report_file_path(FilePath("."), written_report_header, report_id) with written_report_path.open('r') as f: self.filenames.add(written_report_path.path) written_report = yaml.safe_load_all(f) written_report.next() for i in range(report_entry_count): self.assertEqual(yaml.safe_load(sample_report_entry_yaml), written_report.next())