Beispiel #1
0
 def test_managers(self):
     p = ProjectFactory()
     u = UserProfileFactory()
     p.add_manager(u)
     self.assertEqual(set(p.managers()),
                      set([u, p.caretaker_user.userprofile,
                           p.project_manager_user.userprofile]))
Beispiel #2
0
    def setUp(self):
        self.u = User.objects.create(username="******")
        self.client.force_authenticate(user=self.u)

        self.project1 = ProjectFactory(name='Project 1')
        self.project2 = ProjectFactory(name='Test Project 2')
        self.project3 = ProjectFactory(name='Testing number 3')
        self.project4 = ProjectFactory(name='abcdefg (project)')
Beispiel #3
0
    def test_personnel_present(self):
        u1 = UserProfileFactory()
        u2 = UserProfileFactory()
        u3 = UserProfileFactory()
        p = ProjectFactory()
        p.add_personnel(u3)
        f = ProjectPersonnelForm(pid=p.pid)

        personnel_in_form = f.fields.get('personnel').queryset.all()
        self.assertTrue(u1 in personnel_in_form)
        self.assertTrue(u2 in personnel_in_form)
        self.assertFalse(u3 in personnel_in_form)
Beispiel #4
0
 def test_remove_personnel(self):
     p = ProjectFactory()
     u = UserProfileFactory()
     p.add_manager(u)
     self.assertEqual(
         set(p.managers()),
         set([u, p.caretaker_user.userprofile,
              p.project_manager_user.userprofile]))
     p.remove_personnel(u)
     self.assertEqual(
         set(p.managers()),
         set([p.caretaker_user.userprofile,
              p.project_manager_user.userprofile]))
     self.assertEqual(p.developers(), [])
     self.assertEqual(p.guests(), [])
Beispiel #5
0
    def setUp(self):
        self.title = 'Test item title'
        self.email = '*****@*****.**'
        self.name = 'Item Submitter'
        self.owner = UserProfileFactory()
        self.assignee = UserProfileFactory()
        self.project = ProjectFactory()
        self.milestone = MilestoneFactory(project=self.project)
        self.estimated_time = '1h'
        self.target_date = '2015-01-01'
        self.debug_info = 'debug info: zofjiojfojef'
        self.post_data = {
            'title': self.title,
            'email': self.email,
            'name': self.name,
            'pid': smart_text(self.project.pk),
            'mid': smart_text(self.milestone.pk),
            'type': 'action item',
            'owner': self.owner.username,
            'assigned_to': self.assignee.username,
            'estimated_time': self.estimated_time,
            'target_date': self.target_date,
            'debug_info': self.debug_info,
        }

        # Mock for passing the SafeOriginPermission
        self.remote_host = 'http://example.columbia.edu'
Beispiel #6
0
 def test_calc(self):
     ProjectFactory()
     UserProfileFactory()
     UserProfileFactory()
     UserProfileFactory()
     calc = ProjectStatusCalculator()
     calc.calc()
 def test_completed_time_for_interval(self):
     u = UserProfileFactory()
     p = ProjectFactory()
     pu = ProjectUser(p, u)
     start = datetime(year=2013, month=12, day=16).replace(tzinfo=utc)
     end = datetime(year=2013, month=12, day=23).replace(tzinfo=utc)
     r = pu.completed_time_for_interval(start, end)
     self.assertEqual(r.total_seconds(), 0.0)
Beispiel #8
0
 def test_personnel_in_project_sorts_groups_first(self):
     p = ProjectFactory()
     u = UserProfileFactory()
     g = GroupFactory()
     p.add_manager(u)
     p.add_manager(g.grp)
     r = p.personnel_in_project()
     self.assertEqual(set(r), set([g.grp, u, p.caretaker_user.userprofile,
                                   p.project_manager_user.userprofile]))
Beispiel #9
0
    def test_email_reply_with_bad_header(self):
        n = NodeFactory()
        p = ProjectFactory()
        n.project = p
        u = UserProfileFactory()
        n.save()

        class DummyReply(object):
            subject = "a subject\r\nfoo"
        n.email_reply("", u, DummyReply())
        self.assertEqual(len(mail.outbox), 1)
 def test_all_users_not_in_project(self):
     p = ProjectFactory()
     u1 = UserProfileFactory(status='active')
     u2 = UserProfileFactory(status='active')
     p.add_manager(u1)
     self.assertTrue(u2 in p.all_users_not_in_project())
     self.assertFalse(u1 in p.all_users_not_in_project())
 def test_email_post(self):
     p = ProjectFactory()
     n = NodeFactory(subject="\r\n \r\n linebreaks", project=p)
     u2 = UserProfileFactory(status='active')
     p.add_manager(u2)
     p.email_post(n, "a body", n.user.userprofile)
     self.assertEqual(len(mail.outbox), 1)
Beispiel #12
0
 def test_ensure_caretaker_in_personnel(self):
     p = ProjectFactory()
     WorksOn.objects.filter(project=p, user=p.caretaker_user).delete()
     self.assertEqual(p.managers(), [p.project_manager_user.userprofile])
     p.ensure_caretaker_in_personnel()
     self.assertEqual(set(p.managers()),
                      set([p.caretaker_user.userprofile,
                           p.project_manager_user.userprofile]))
    def test_toggle_pin(self):
        p = ProjectFactory()
        u = UserFactory()

        self.assertEqual(p.projectpin_set.count(), 0)

        p.toggle_pin(u)
        self.assertEqual(p.projectpin_set.count(), 1)

        p.toggle_pin(u)
        self.assertEqual(p.projectpin_set.count(), 0)
 def test_guests_empty(self):
     p = ProjectFactory()
     self.assertEqual(p.guests(), [])
Beispiel #15
0
 def test_calc(self):
     ProjectFactory()
     calc = TimeSpentByProjectCalculator()
     calc.calc()
 def test_add_milestone_invalid_target_date(self):
     p = ProjectFactory()
     with self.assertRaises(forms.ValidationError):
         p.add_milestone('name', 'not a date', 'desc')
 def test_add_milestone_valid_target_date(self):
     p = ProjectFactory()
     p.add_milestone('name', '2020-04-04', 'desc')
     p.add_milestone('name', '2020-04-4', 'desc')
     p.add_milestone('name', '2020-4-04', 'desc')
     self.assertEqual(Milestone.objects.filter(project=p).count(), 3)
 def test_timeline_empty(self):
     p = ProjectFactory()
     self.assertEqual(p.timeline(), [])
 def test_all_personnel_in_project(self):
     p = ProjectFactory()
     g = GroupFactory()
     p.add_manager(g.grp)
     self.assertTrue(g.username in p.all_personnel_in_project())
    def test_only_one_role_allowed(self):
        p = ProjectFactory()
        u = UserProfileFactory()
        p.add_manager(u)
        self.assertEqual(
            set(p.managers()),
            set([
                u, p.caretaker_user.userprofile,
                p.project_manager_user.userprofile
            ]))
        self.assertEqual(p.developers(), [])
        self.assertEqual(p.guests(), [])
        p.add_developer(u)
        self.assertEqual(p.managers(), [p.caretaker_user.userprofile])
        self.assertEqual(p.developers(), [u])
        self.assertEqual(p.guests(), [])
        p.add_guest(u)
        self.assertEqual(p.managers(), [p.caretaker_user.userprofile])
        self.assertEqual(p.developers(), [])
        self.assertEqual(p.guests(), [u])

        p.add_manager(u)
        self.assertEqual(
            set(p.managers()),
            set([
                u, p.caretaker_user.userprofile,
                p.project_manager_user.userprofile
            ]))
        self.assertEqual(p.developers(), [])
        self.assertEqual(p.guests(), [])
        p.add_developer(u)
        self.assertEqual(
            p.managers(),
            [p.caretaker_user.userprofile, p.project_manager_user.userprofile])
        self.assertEqual(p.developers(), [u])
        self.assertEqual(p.guests(), [])
        p.add_guest(u)
        self.assertEqual(
            p.managers(),
            [p.caretaker_user.userprofile, p.project_manager_user.userprofile])
        self.assertEqual(p.developers(), [])
        self.assertEqual(p.guests(), [u])
 def test_guests(self):
     p = ProjectFactory()
     u = UserProfileFactory()
     p.add_guest(u)
     self.assertEqual(p.guests(), [u])
 def test_managers_empty(self):
     p = ProjectFactory()
     self.assertEqual(
         p.managers(),
         [p.caretaker_user.userprofile, p.project_manager_user.userprofile])
 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_open_milestones_empty(self):
     p = ProjectFactory()
     self.assertEqual(len(p.open_milestones()), 0)
 def test_developers_empty(self):
     p = ProjectFactory()
     self.assertEqual(p.developers(), [])
Beispiel #26
0
 def test_init(self):
     p = ProjectFactory()
     ProjectPersonnelForm(pid=p.pid)
 def test_developers(self):
     p = ProjectFactory()
     u = UserProfileFactory()
     p.add_developer(u)
     self.assertEqual(p.developers(), [u])