def test_get_grand_total_on_summary_report(self): report = ReportParser( self.build_mock_report('summary_basic_single_group')) grand_total = report.get_grand_total() self.assertEquals(grand_total, 9469000000)
def test_get_records_simple_summary(self): report = ReportParser(self.build_mock_report('summary_basic_single_group')) records = report.records() self.assertEquals(len(records), 13) self.assertEquals(records[0][0], 'Chris Hall')
def test_get_record_dict_simple_tabular(self): report = ReportParser(self.build_mock_report('tabular_basic')) records = report.records_dict() field_value = records[0]["Mailing Street"] self.assertEquals(len(records), 20) self.assertIsNotNone(field_value)
def test_get_record_dict_simple_summary(self): report = ReportParser(self.build_mock_report('summary_basic_single_group')) records = report.records_dict() field_value = records[0]["Created Date"] self.assertEquals(len(records), 13) self.assertIsNotNone(field_value)
def test_get_records_simple_summary(self): report = ReportParser( self.build_mock_report('summary_basic_single_group')) records = report.records() self.assertEquals(len(records), 13) self.assertEquals(records[0][0], 'Chris Hall')
def test_get_record_dict_simple_summary(self): report = ReportParser( self.build_mock_report('summary_basic_single_group')) records = report.records_dict() field_value = records[0]["Created Date"] self.assertEquals(len(records), 13) self.assertIsNotNone(field_value)
def sf_report_to_sheet_and_edit_type(report_id, sheet_name): report = ReportParser(sf.get_report(report_id, details=True)).records() for value in report: value[4] = value[4].replace("$", "").replace("(", "").replace( ")", "").replace(",", "").replace("-", "0") value[4] = float(value[4]) excel_sheet = excel_report_template.get_sheet_by_name(sheet_name) for data in report: excel_sheet.append(data)
def load_report(report_id, sf): report_details = sf.get_report(report_id) parser = ReportParser(report_details) report = parser.records_dict() df = pd.DataFrame(report) while report_details["allData"] == False: existing_ids = ",".join(list(df["18 Digit ID"])) reportFilter = [{ "value": f"{existing_ids}", "operator": "notEqual", "column": "Contact.X18_Digit_ID__c", }] report_details = sf.get_report(report_id, filters=reportFilter) _parser = ReportParser(report_details) _report = _parser.records_dict() _df = pd.DataFrame(_report) df = df.append(_df, ignore_index=True) return df
def sf_report_to_excel_sheet(report_id, sheet_name): report = ReportParser(sf.get_report(report_id, details=True)).records() excel_sheet = excel_report_template.get_sheet_by_name(sheet_name) for data in report: excel_sheet.append(data)
def load_report(report_id, sf): report = sf.get_report(report_id) parser = ReportParser(report) report = parser.records_dict() report = pd.DataFrame(report) return report
def test_get_grand_total_on_matrix_report(self): report = ReportParser(self.build_mock_report('matrix_basic')) grand_total = report.get_grand_total() self.assertEquals(grand_total, 3645000)
def test_get_records_simple_tabular(self): report = ReportParser(self.build_mock_report('tabular_basic')) records = report.records() self.assertEquals(len(records), 20) self.assertEquals(records[1][2], 'James')
def test_get_grand_total_on_summary_report(self): report = ReportParser(self.build_mock_report('summary_basic_single_group')) grand_total = report.get_grand_total() self.assertEquals(grand_total, 9469000000)
def test_get_records_basic_matrix(self): report = ReportParser(self.build_mock_report('matrix_basic')) records = report.records() self.assertEquals(len(records), 18)
def test_get_records_dict_without_details(self): report = ReportParser(self.build_mock_report('matrix_complex')) self.assertRaises(ValueError, report.records_dict)