def volumetrics(sheets): sheet = list(list(sheets)[2]) yield ["_timestamp", "service", "channel", "transaction", "volume"] header, rows = extract_transaction_rows(remove_summary_columns(sheet)) for row in rows: for data in create_transaction_data(header, row): yield data
def test_extracts_transaction_rows_from_sheet(self): sheet = [ ["Ignore"], ["Ignore"], ["Ignore"], ["Channel Descriptions", "", "Transaction", "Apr 2012"], ["Assisted Digital", "Relicensing", "V-V10 Licence Application Post Office", 1000], ["", "", "V-V11 Licence Renewal Reminder Post Office", 1001], ["Ignore"], ["", "SORN", "V-V11 Some transaction", 1003], ["Ignore"], ["Ignore"], ["Fully Digital", "Relicensing", "V-V10 Licence Application EVL", 1006], ["", "", "V-V11 Fleets", 1007], ["", "", "V-V11 Licence Renewal Reminder EVL", 1008], ["", "", "V-V85 and V85/1 HGV Licence Application EVL", 1009], ["Ignore"], ["", "SORN", "V-V11 SORN EVL", 1011], ["", "", "V-V85/1 HGV SORN Declaration EVL", 1012], ["", "", "V-V890 SORN Declaration EVL", 1013], ["", "", "V-V890 SORN Declaration Fleets", 1014], ["Ignore"], ["Ignore"], ["Manual", "Relicensing", "V-V890 Another transaction", 1017], ["", "", "V-V11 Licence Renewal Reminder Local Office", 1018], ["", "", "V-V85 and V85/1 HGV Licence Application", 1019], ["Ignore"], ["", "SORN", "V-V11 SORN Local Office", 1021], ["", "", "V-V85/1 HGV SORN Declaration", 1022], ["", "", "V-V890 SORN Declaration", 1023], ["", "", "V-V890 SORN Declaration Key from Image", 1024], ["", "", "V-V890 SORN Declaration Refunds Input", 1025], ["", "", "V-V890 SORN Declaration Vehicles Input", 1026], ["", "", "V-V890 SORN Declaration Vehicles Triage", 1027], ["Ignore"], ["Ignore"], ["Ignore"] ] header, rows = extract_transaction_rows(sheet) assert_that(header, is_(["Channel Descriptions", "", "Transaction", "Apr 2012"])) assert_that(rows, is_not(has_item(["Ignore"]))) assert_that(rows, has_items( ["Assisted Digital", "Relicensing", "V-V10 Licence Application Post Office", 1000], ["Assisted Digital", "Relicensing", "V-V11 Licence Renewal Reminder Post Office", 1001], ["Assisted Digital", "SORN", "V-V11 Some transaction", 1003], ["Fully Digital", "Relicensing", "V-V10 Licence Application EVL", 1006], ["Fully Digital", "Relicensing", "V-V11 Fleets", 1007], ["Fully Digital", "Relicensing", "V-V11 Licence Renewal Reminder EVL", 1008], ["Fully Digital", "Relicensing", "V-V85 and V85/1 HGV Licence Application EVL", 1009], ["Fully Digital", "SORN", "V-V11 SORN EVL", 1011], ["Fully Digital", "SORN", "V-V85/1 HGV SORN Declaration EVL", 1012], ["Fully Digital", "SORN", "V-V890 SORN Declaration EVL", 1013], ["Fully Digital", "SORN", "V-V890 SORN Declaration Fleets", 1014], ["Manual", "Relicensing", "V-V890 Another transaction", 1017], ["Manual", "Relicensing", "V-V11 Licence Renewal Reminder Local Office", 1018], ["Manual", "Relicensing", "V-V85 and V85/1 HGV Licence Application", 1019], ["Manual", "SORN", "V-V11 SORN Local Office", 1021], ["Manual", "SORN", "V-V85/1 HGV SORN Declaration", 1022], ["Manual", "SORN", "V-V890 SORN Declaration", 1023], ["Manual", "SORN", "V-V890 SORN Declaration Key from Image", 1024], ["Manual", "SORN", "V-V890 SORN Declaration Refunds Input", 1025], ["Manual", "SORN", "V-V890 SORN Declaration Vehicles Input", 1026], ["Manual", "SORN", "V-V890 SORN Declaration Vehicles Triage", 1027] ))