def test_end_of_month(self): self.average_month = datetime.date(2011,6,1) self.leap_year = datetime.date(2004,2,1) self.already_at_month_end = datetime.date(2011,8,31) self.assertEqual(Milestone.end_of_month(self.average_month), datetime.date(2011,6,30)) self.assertEqual(Milestone.end_of_month(self.leap_year), datetime.date(2004,2,29)) self.assertEqual(Milestone.end_of_month(self.already_at_month_end), datetime.date(2011,8,31))
def milestone_index(request): project = Project.objects.get(pk=1) Milestone.safe_for_democracy() overdue_milestone_list = Milestone.objects.filter(is_past=True).filter(is_complete=False) current_milestone = Milestone.objects.get(end_date__month=datetime.date.today().month) future_milestone_list = Milestone.objects.filter(end_date__gt=Milestone.end_of_month(datetime.date.today())) unaffiliated_issues = Issue.objects.filter(milestone__isnull=True) return render_to_response( "milestones/milestone-dashboard.html", { "project_name": project_name, "overdue_milestone_list": overdue_milestone_list, "current_milestone": current_milestone, "future_milestone_list": future_milestone_list, "unaffiliated_issues": unaffiliated_issues, }, )
def create_fake_data(): num_issues = 100 num_vaqueritas = 20 # make one old milestone m = Milestone(name="1.70",description="Really ancient milestone", end_date=datetime.date(1970,1,1)) m.save() # make four other milestones using Milestone's update script -- one current, three future Milestone.safe_for_democracy() v = Faker() while num_vaqueritas > 0: vaquerita = Vaquerita.objects.create_user(username=v.username(),email=v.email()) vaquerita.is_maintainer = dice_roll(8) vaquerita.save() num_vaqueritas = num_vaqueritas - 1 while num_issues > 0: issue = IssueFactory() num_issues = num_issues - 1
def test_generate_enddate(self): self.date = datetime.date(2011,6,1) self.other_date = datetime.date(2011,7,31) self.december = datetime.date(2010,11,3) self.frozen_today = datetime.date(2011,8,18) self.assertEqual(Milestone.generate_enddate(self.date,1), datetime.date(2011,7,31)) self.assertEqual(Milestone.generate_enddate(self.date,14), datetime.date(2012,8,31)) self.assertEqual(Milestone.generate_enddate(self.date,7), datetime.date(2012,1,31)) self.assertEqual(Milestone.generate_enddate(self.other_date,2), datetime.date(2011,9,30)) self.assertEqual(Milestone.generate_enddate(self.december,1), datetime.date(2010,12,31)) self.assertEqual(Milestone.generate_enddate(self.frozen_today,3), datetime.date(2011,11,30))
def test_safe_for_democracy(self): self.today = datetime.date(2011,8,19) Milestone.safe_for_democracy(self.today)
def current_milestone(request): project = Project.objects.get(pk=1) Milestone.safe_for_democracy() milestone = Milestone.objects.get(end_date__month=datetime.date.today().month) return render_to_response("milestones/milestone.html", {"project_name": project_name, "milestone": milestone})