def test_num_packages_by_week(self): num_packages_by_week = RevisionStats.get_num_packages_by_week() # e.g. [('2011-05-30', 3, 3)] assert_equal(num_packages_by_week[0], ('2011-01-03', 4, 4)) assert_equal(num_packages_by_week[1], ('2011-01-10', -1, 3)) assert_equal(num_packages_by_week[2], ('2011-01-17', 0, 3)) assert_equal(num_packages_by_week[3], ('2011-01-24', 0, 3))
def test_new_packages_by_week(self): new_packages_by_week = RevisionStats.get_by_week('new_packages') def get_results(week_number): date, ids, num, cumulative = new_packages_by_week[week_number] return (date, set([model.Session.query(model.Package).get(id).name for id in ids]), num, cumulative) assert_equal(get_results(0), ('2011-01-03', set((u'test1', u'test2', u'test3', u'test4')), 4, 4)) assert_equal(get_results(1), ('2011-01-10', set([]), 0, 4)) assert_equal(get_results(2), ('2011-01-17', set([]), 0, 4)) assert_equal(get_results(3), ('2011-01-24', set([]), 0, 4))
def test_deleted_packages_by_week(self): deleted_packages_by_week = RevisionStats.get_by_week('deleted_packages') def get_results(week_number): date, ids, num, cumulative = deleted_packages_by_week[week_number] return (date, [model.Session.query(model.Package).get(id).name for id in ids], num, cumulative) assert_equal(get_results(0), ('2011-01-10', [u'test2'], 1, 1)) assert_equal(get_results(1), ('2011-01-17', [], 0, 1)) assert_equal(get_results(2), ('2011-01-24', [], 0, 1)) assert_equal(get_results(3), ('2011-01-31', [], 0, 1))
def test_revisions_by_week(self): revisions_by_week = RevisionStats.get_by_week('package_revisions') def get_results(week_number): date, ids, num, cumulative = revisions_by_week[week_number] return (date, num, cumulative) num_setup_revs = revisions_by_week[0][2] assert 6 > num_setup_revs > 2, num_setup_revs assert_equal(get_results(0), ('2011-01-03', num_setup_revs, num_setup_revs)) assert_equal(get_results(1), ('2011-01-10', 1, num_setup_revs + 1)) assert_equal(get_results(2), ('2011-01-17', 2, num_setup_revs + 3)) assert_equal(get_results(3), ('2011-01-24', 1, num_setup_revs + 4))
def test_deleted_packages_by_week(self): deleted_packages_by_week = RevisionStats.get_by_week( 'deleted_packages') def get_results(week_number): date, ids, num, cumulative = deleted_packages_by_week[week_number] return (date, [ model.Session.query(model.Package).get(id).name for id in ids ], num, cumulative) assert_equal(get_results(0), ('2011-01-10', [u'test2'], 1, 1)) assert_equal(get_results(1), ('2011-01-17', [], 0, 1)) assert_equal(get_results(2), ('2011-01-24', [], 0, 1)) assert_equal(get_results(3), ('2011-01-31', [], 0, 1))
def test_revisions_by_week(self): revisions_by_week = RevisionStats.get_by_week('package_revisions') def get_results(week_number): date, ids, num, cumulative = revisions_by_week[week_number] return (date, num, cumulative) num_setup_revs = revisions_by_week[0][2] assert 6 > num_setup_revs > 2, num_setup_revs assert_equal(get_results(0), ('2011-01-03', num_setup_revs, num_setup_revs)) assert_equal(get_results(1), ('2011-01-10', 1, num_setup_revs+1)) assert_equal(get_results(2), ('2011-01-17', 2, num_setup_revs+3)) assert_equal(get_results(3), ('2011-01-24', 1, num_setup_revs+4))
def test_new_packages_by_week(self): new_packages_by_week = RevisionStats.get_by_week('new_packages') def get_results(week_number): date, ids, num, cumulative = new_packages_by_week[week_number] return (date, set([ model.Session.query(model.Package).get(id).name for id in ids ]), num, cumulative) assert_equal( get_results(0), ('2011-01-03', set( (u'test1', u'test2', u'test3', u'test4')), 4, 4)) assert_equal(get_results(1), ('2011-01-10', set([]), 0, 4)) assert_equal(get_results(2), ('2011-01-17', set([]), 0, 4)) assert_equal(get_results(3), ('2011-01-24', set([]), 0, 4))