def test_no_current_streak(self): user = UserFactory.create(groups=['Rep']) for i in range(4): report_date = date(2011, 01, 01) + timedelta(weeks=i) NGReportFactory.create(user=user, report_date=report_date) calculate_longest_streaks() eq_(user.userprofile.longest_streak_start, date(2011, 01, 01)) eq_(user.userprofile.longest_streak_end, date(2011, 01, 22))
def test_no_current_streak(self): user = UserFactory.create(groups=['Rep']) for i in range(4): report_date = date(2011, 1, 1) + timedelta(weeks=i) NGReportFactory.create(user=user, report_date=report_date) calculate_longest_streaks() eq_(user.userprofile.longest_streak_start, date(2011, 1, 1)) eq_(user.userprofile.longest_streak_end, date(2011, 1, 22))
def test_with_larger_current_streak(self): user = UserFactory.create(groups=["Rep"]) for i in range(4): report_date = date.today() - timedelta(weeks=i) NGReportFactory.create(user=user, report_date=report_date) eq_(user.userprofile.longest_streak_start, date.today() - timedelta(weeks=3)) eq_(user.userprofile.longest_streak_end, date.today()) for i in range(3): report_date = date(2011, 01, 01) + timedelta(weeks=i) NGReportFactory.create(user=user, report_date=report_date) calculate_longest_streaks() user = User.objects.get(pk=user.id) eq_(user.userprofile.longest_streak_start, date.today() - timedelta(weeks=3)) eq_(user.userprofile.longest_streak_end, date.today())
def test_with_smaller_current_streak(self): user = UserFactory.create(groups=['Rep']) for i in range(3): report_date = date.today() - timedelta(weeks=i) NGReportFactory.create(user=user, report_date=report_date) eq_(user.userprofile.longest_streak_start, date.today() - timedelta(weeks=2)) eq_(user.userprofile.longest_streak_end, date.today()) for i in range(4): report_date = date(2011, 1, 1) + timedelta(weeks=i) NGReportFactory.create(user=user, report_date=report_date) calculate_longest_streaks() user = User.objects.get(pk=user.id) eq_(user.userprofile.longest_streak_start, date(2011, 1, 1)) eq_(user.userprofile.longest_streak_end, date(2011, 1, 22))