def setUp(self): self.c = self.client self.u = User.objects.create(username="******") self.u.set_password("test") self.u.save() self.c.login(username="******", password="******") self.milestone = MilestoneFactory() self.project = self.milestone.project self.url = reverse('add-tracker')
def test_timeline_notempty(self): m = MilestoneFactory() p = m.project u = UserProfileFactory() p.add_item(type='action item', title="new item", assigned_to=u, owner=u, milestone=m, priority=1, description="", estimated_time="2 hours", status='OPEN', r_status='') t = p.timeline() self.assertEqual(len(t), 1)
def setUp(self): self.c = Client() self.u = User.objects.create(username="******") self.u.set_password("test") self.u.save() self.c.login(username="******", password="******") pu = PMTUser.objects.create(username="******", email="*****@*****.**", status="active") Claim.objects.create(django_user=self.u, pmt_user=pu) m = MilestoneFactory() self.project = m.project
def test_close_empty_milestone(self): m = MilestoneFactory() self.assertEqual(m.status, "OPEN") m.close_milestone() self.assertEqual(m.status, "CLOSED") m.close_milestone() self.assertEqual(m.status, "CLOSED")
def test_add_item_invalid_duration(self): m = MilestoneFactory() p = m.project u = UserProfileFactory() p.add_item(type='action item', title="new item", assigned_to=u, owner=u, milestone=m, priority=1, description="", estimated_time="Invalid Estimated Time", status='OPEN', r_status='') self.assertTrue(m.item_set.count() > 0) i = m.item_set.first() self.assertEqual(i.estimated_time.seconds, 0) self.assertEqual(Reminder.objects.count(), 0)
def test_resolve(self): m = MilestoneFactory() p = m.project u = UserProfileFactory() p.add_item( type='action item', title='new item', assigned_to=u, owner=u, milestone=m, priority=1, description='', estimated_time='1hr', status='OPEN', r_status='') i = m.item_set.first() i.resolve(u, 'FIXED', 'test comment') self.assertEqual( Events.objects.filter(item=i, status='RESOLVED').count(), 1)
def test_add_item_created_by(self): m = MilestoneFactory() p = m.project current_user = UserFactory() u = UserProfileFactory() p.add_item( type='action item', title='new item', assigned_to=u, owner=u, milestone=m, current_user=current_user, priority=1, description='', estimated_time='2 hours', status='OPEN', r_status='') self.assertEqual(m.item_set.count(), 1) item = m.item_set.first() self.assertEqual(item.created_by, current_user)
def test_open_owned_items(self): profile = UserProfileFactory() # not the owner ItemFactory(assigned_user=profile.user) # owned but in the Someday/Maybe milestone s = MilestoneFactory(name='Someday/Maybe') ItemFactory(owner_user=profile.user, milestone=s) # owned i = ItemFactory(owner_user=profile.user) qs = profile.open_owned_items() self.assertEquals(qs.count(), 1) self.assertEquals(qs.first(), i)
def test_add_item_valid_duration_and_timezone(self): m = MilestoneFactory() p = m.project u = UserProfileFactory() p.add_item(type='action item', title="new item", assigned_to=u, owner=u, milestone=m, priority=1, description="", estimated_time="2 hours", status='OPEN', r_status='') self.assertTrue(m.item_set.count() > 0) i = m.item_set.first() self.assertEqual(i.estimated_time.seconds, 7200) # Assert that the last_mod time is within ten mins of what # we expect. now = timezone.now() five_mins = timedelta(minutes=5) self.assertTrue(i.last_mod < (now + five_mins)) self.assertTrue(i.last_mod > (now - five_mins)) self.assertEqual(Reminder.objects.count(), 0)
def test_add_item_with_reminder(self): m = MilestoneFactory() p = m.project u = UserProfileFactory() p.add_item(type='action item', title='new item', assigned_to=u, owner=u, milestone=m, priority=1, description='', estimated_time='2 hours', status='OPEN', r_status='', reminder_duration='7d') self.assertEqual(m.item_set.count(), 1) self.assertEqual(Reminder.objects.count(), 0, 'add_reminder requires a current_user') # Same thing, with a current_user i = p.add_item(type='action item', title='new item', assigned_to=u, owner=u, milestone=m, priority=1, description='', estimated_time='2 hours', status='OPEN', r_status='', current_user=u.user, reminder_duration='7d') self.assertEqual(m.item_set.count(), 2) self.assertEqual(Reminder.objects.count(), 1) r = Reminder.objects.first() self.assertEqual(r.item, i) self.assertEqual(r.reminder_time, timedelta(days=7))
def test_open_milestones(self): p = ProjectFactory() MilestoneFactory(project=p, status='CLOSED') self.assertEqual(len(p.milestones()), 1) self.assertEqual(len(p.open_milestones()), 0)
def test_estimated_time_remaining(self): m = MilestoneFactory() self.assertEqual(m.estimated_time_remaining(), 0.)
def test_update_milestone_passed_milestone(self): m = MilestoneFactory( target_date=datetime(year=2000, month=1, day=1).date()) m.update_milestone() self.assertEqual(m.status, "CLOSED")
def test_should_be_closed_passed_milestone(self): m = MilestoneFactory( target_date=datetime(year=2000, month=1, day=1).date()) self.assertTrue(m.should_be_closed())
def test_num_unclosed_items_empty_milestone(self): m = MilestoneFactory() self.assertEqual(m.num_unclosed_items(), 0)
def test_report(self): m = MilestoneFactory(target_date='2000-01-01', status='OPEN') r = self.client.get(reverse('passed_milestones_report')) self.assertEqual(r.status_code, 200) self.assertContains(r, m.name)