def test_weekly_totals_timestamp(self): ''' A list of (datetime, id) tuples is correctly grouped into weekly batches with correct translated datetime --> timestamp values. ''' weekly_totals = swe_helpers._weekly_totals(self.l, timestamp=True, zero_week=False) nosetools.assert_equal(len(weekly_totals), 3) # 2 in w/c 29 dec 2014 nosetools.assert_equal(weekly_totals[0][0], 1419811200000) nosetools.assert_equal(weekly_totals[0][1], 2) # 1 in w/c 19 jan 2015 nosetools.assert_equal(weekly_totals[1][0], 1421625600000) nosetools.assert_equal(weekly_totals[1][1], 1) # 4 in w/c 9 feb 2015 nosetools.assert_equal(weekly_totals[2][0], 1423440000000) nosetools.assert_equal(weekly_totals[2][1], 4)
def test_weekly_totals_cumulative(self): ''' A list of (datetime, id) tuples is correctly grouped into weekly batches with correct cumulative weekly totals. ''' weekly_totals = swe_helpers._weekly_totals(self.l, cumulative=True, zero_week=False) nosetools.assert_equal(len(weekly_totals), 3) # 2 in w/c 29 dec 2014 nosetools.assert_equal(weekly_totals[0][0], datetime.date(2014, 12, 29)) nosetools.assert_equal(weekly_totals[0][1], 2) # 1 in w/c 19 jan 2015 nosetools.assert_equal(weekly_totals[1][0], datetime.date(2015, 1, 19)) nosetools.assert_equal(weekly_totals[1][1], 3) # 4 in w/c 9 feb 2015 nosetools.assert_equal(weekly_totals[2][0], datetime.date(2015, 2, 9)) nosetools.assert_equal(weekly_totals[2][1], 7)