def test_converts_missing_failure_as_zero(self): timestamp = d_tz(2013, 7, 30) failures_raw_data = [ ["First sheet to be ignored"], self.ignore_rows(1) + [["Date", timestamp]] + self.ignore_rows(4) + [["No tax-disc failure", 0, '', 0, 2]] + [["No sorn failure", 1, 20, 0, '']] + [["", "Blank first column means end of failures list"]] ] data = list(service_failures(failures_raw_data)) assert_that(data, is_([ ["_timestamp", "_id", "type", "reason", "count", "description"], [timestamp, "2013-07-30.tax-disc.0", "tax-disc", 0, 0, "No tax-disc failure"], [timestamp, "2013-07-30.sorn.0", "sorn", 0, 2, "No tax-disc failure"], [timestamp, "2013-07-30.tax-disc.1", "tax-disc", 1, 20, "No sorn failure"], [timestamp, "2013-07-30.sorn.1", "sorn", 1, 0, "No sorn failure"], ]))
def test_converts_missing_failure_as_zero(self): timestamp = d_tz(2013, 7, 30) failures_raw_data = [ ["First sheet to be ignored"], self.ignore_rows(1) + [["Date", timestamp]] + self.ignore_rows(4) + [["No tax-disc failure", 0, '', 0, 2]] + [["No sorn failure", 1, 20, 0, '']] + [["", "Blank first column means end of failures list"]] ] data = list(service_failures(failures_raw_data)) assert_that(data, is_([ ["_timestamp", "_id", "type", "reason", "count", "description"], [timestamp, "2013-07-30.tax-disc.0", "tax-disc", 0, 0, "No tax-disc failure"], [timestamp, "2013-07-30.sorn.0", "sorn", 0, 2, "No tax-disc failure"], [timestamp, "2013-07-30.tax-disc.1", "tax-disc", 1, 20, "No sorn failure"], [timestamp, "2013-07-30.sorn.1", "sorn", 1, 0, "No sorn failure"], ]))
def test_converts_service_failures_data_to_normalised_data(self): timestamp = d_tz(2013, 7, 30) failures_raw_data = [ ["First sheet to be ignored"], self.ignore_rows(1) + [["Date", timestamp]] + self.ignore_rows(4) + [["Failure 1", 0, 10, 0, 2]] + [["Failure 2", 1, 20, 0, 3]] + [["Failure 3", 2, 30, 0, 4]] + [["", "Blank first column means end of failures list"]] ] data = list(service_failures(failures_raw_data)) assert_that(data, is_([ ["_timestamp", "_id", "type", "reason", "count", "description"], [timestamp, "2013-07-30.tax-disc.0", "tax-disc", 0, 10, "Failure 1"], [timestamp, "2013-07-30.sorn.0", "sorn", 0, 2, "Failure 1"], [timestamp, "2013-07-30.tax-disc.1", "tax-disc", 1, 20, "Failure 2"], [timestamp, "2013-07-30.sorn.1", "sorn", 1, 3, "Failure 2"], [timestamp, "2013-07-30.tax-disc.2", "tax-disc", 2, 30, "Failure 3"], [timestamp, "2013-07-30.sorn.2", "sorn", 2, 4, "Failure 3"] ]))
def test_converts_service_failures_data_to_normalised_data(self): timestamp = d_tz(2013, 7, 30) failures_raw_data = [ ["First sheet to be ignored"], self.ignore_rows(1) + [["Date", timestamp]] + self.ignore_rows(4) + [["Failure 1", 0, 10, 0, 2]] + [["Failure 2", 1, 20, 0, 3]] + [["Failure 3", 2, 30, 0, 4]] + [[None, "None in first column means end of failures list"]] ] data = list(service_failures(failures_raw_data)) assert_that(data, is_([ ["_timestamp", "_id", "type", "reason", "count", "description"], [timestamp, "2013-07-30.tax-disc.0", "tax-disc", 0, 10, "Failure 1"], [timestamp, "2013-07-30.sorn.0", "sorn", 0, 2, "Failure 1"], [timestamp, "2013-07-30.tax-disc.1", "tax-disc", 1, 20, "Failure 2"], [timestamp, "2013-07-30.sorn.1", "sorn", 1, 3, "Failure 2"], [timestamp, "2013-07-30.tax-disc.2", "tax-disc", 2, 30, "Failure 3"], [timestamp, "2013-07-30.sorn.2", "sorn", 2, 4, "Failure 3"] ]))