示例#1
0
  def testPostButtonNeedsWork(self):
    """Tests the needs more work for task button.
    """
    self.data.createMentor(self.org)

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createOtherUser('*****@*****.**').createStudent()
    student = profile_helper.profile

    self.task.status = 'NeedsReview'
    self.task.student = student
    self.task.put()

    url = self._taskPageUrl(self.task)
    response = self.buttonPost(url, 'button_needs_work')

    # check if the task is properly closed
    task = GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertEqual(task.status, 'NeedsWork')
    self.assertEqual(task.student.key(), student.key())
    self.assertEqual(task.deadline, None)

    # check if a comment has been created
    comments = self.task.comments()
    self.assertLength(comments, 1)
    self.assertMailSentToSubscribers(comments[0])
示例#2
0
  def testPostButtonExtendDeadline(self):
    """Tests the extend deadline button.
    """
    self.data.createMentor(self.org)

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createOtherUser('*****@*****.**').createStudent()
    student = profile_helper.profile

    # set it in the future so that the auto state transfer doesn't trigger
    deadline = datetime.datetime.utcnow() + datetime.timedelta(hours=24)

    self.task.status = 'Claimed'
    self.task.student = student
    self.task.deadline = deadline
    self.task.put()

    url = self._taskPageUrl(self.task)
    response = self.buttonPost(
        url, 'button_extend_deadline', {'hours': 1})

    task = GCITask.get(self.task.key())
    self.assertResponseRedirect(response)

    delta = task.deadline - deadline
    self.assertTrue(delta.seconds == 3600)

    # check if a comment has been created
    comments = self.task.comments()
    self.assertLength(comments, 1)
    self.assertMailSentToSubscribers(comments[0])
示例#3
0
  def testPostButtonAssign(self):
    """Tests the assign button.
    """
    self.data.createMentor(self.org)

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createOtherUser('*****@*****.**').createStudent()
    student = profile_helper.profile

    self.task.status = 'ClaimRequested'
    self.task.student = student
    self.task.put()

    url = self._taskPageUrl(self.task)
    response = self.buttonPost(url, 'button_assign')

    # check if the task is properly assigned and a deadline has been set
    task = GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertEqual(task.status, 'Claimed')
    self.assertEqual(task.student.key(), student.key())
    self.assertTrue(task.deadline)

    # check if a comment has been created
    comments = self.task.comments()
    self.assertLength(comments, 1)
    self.assertMailSentToSubscribers(comments[0])

    # check if the update task has been enqueued
    self.assertTasksInQueue(n=1, url=self._taskUpdateUrl(task))
示例#4
0
  def testPostButtonUnassign(self):
    """Tests the unassign button.
    """
    self.data.createMentor(self.org)

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createOtherUser('*****@*****.**').createStudent()
    student = profile_helper.profile

    self.task.status = 'Claimed'
    self.task.student = student
    self.task.put()

    url = self._taskPageUrl(self.task)
    response = self.buttonPost(url, 'button_unassign')

    # check if the task is properly unassigned
    task = GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertEqual(task.status, 'Reopened')
    self.assertEqual(task.student, None)
    self.assertEqual(task.deadline, None)

    # check if a comment has been created
    comments = self.task.comments()
    self.assertLength(comments, 1)
    self.assertMailSentToSubscribers(comments[0])
示例#5
0
    def testPostButtonExtendDeadline(self):
        """Tests the extend deadline button.
    """
        self.data.createMentor(self.org)

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createOtherUser("*****@*****.**").createStudent()
        student = profile_helper.profile

        # set it in the future so that the auto state transfer doesn't trigger
        deadline = datetime.datetime.utcnow() + datetime.timedelta(hours=24)

        self.task.status = "Claimed"
        self.task.student = student
        self.task.deadline = deadline
        self.task.put()

        url = self._taskPageUrl(self.task)
        response = self.buttonPost(url, "button_extend_deadline", {"hours": 1})

        task = GCITask.get(self.task.key())
        self.assertResponseRedirect(response)

        delta = task.deadline - deadline
        self.assertTrue(delta.seconds == 3600)

        # check if a comment has been created
        comments = self.task.comments()
        self.assertLength(comments, 1)
        self.assertMailSentToSubscribers(comments[0])
示例#6
0
    def testPostButtonNeedsWork(self):
        """Tests the needs more work for task button.
    """
        self.data.createMentor(self.org)

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createOtherUser("*****@*****.**").createStudent()
        student = profile_helper.profile

        self.task.status = "NeedsReview"
        self.task.student = student
        self.task.put()

        url = self._taskPageUrl(self.task)
        response = self.buttonPost(url, "button_needs_work")

        # check if the task is properly closed
        task = GCITask.get(self.task.key())
        self.assertResponseRedirect(response)
        self.assertEqual(task.status, "NeedsWork")
        self.assertEqual(task.student.key(), student.key())
        self.assertEqual(task.deadline, None)

        # check if a comment has been created
        comments = self.task.comments()
        self.assertLength(comments, 1)
        self.assertMailSentToSubscribers(comments[0])
示例#7
0
    def testPostButtonUnassign(self):
        """Tests the unassign button.
    """
        self.data.createMentor(self.org)

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createOtherUser("*****@*****.**").createStudent()
        student = profile_helper.profile

        self.task.status = "Claimed"
        self.task.student = student
        self.task.put()

        url = self._taskPageUrl(self.task)
        response = self.buttonPost(url, "button_unassign")

        # check if the task is properly unassigned
        task = GCITask.get(self.task.key())
        self.assertResponseRedirect(response)
        self.assertEqual(task.status, "Reopened")
        self.assertEqual(task.student, None)
        self.assertEqual(task.deadline, None)

        # check if a comment has been created
        comments = self.task.comments()
        self.assertLength(comments, 1)
        self.assertMailSentToSubscribers(comments[0])
示例#8
0
    def testPostButtonAssign(self):
        """Tests the assign button.
    """
        self.data.createMentor(self.org)

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createOtherUser("*****@*****.**").createStudent()
        student = profile_helper.profile

        self.task.status = "ClaimRequested"
        self.task.student = student
        self.task.put()

        url = self._taskPageUrl(self.task)
        response = self.buttonPost(url, "button_assign")

        # check if the task is properly assigned and a deadline has been set
        task = GCITask.get(self.task.key())
        self.assertResponseRedirect(response)
        self.assertEqual(task.status, "Claimed")
        self.assertEqual(task.student.key(), student.key())
        self.assertTrue(task.deadline)

        # check if a comment has been created
        comments = self.task.comments()
        self.assertLength(comments, 1)
        self.assertMailSentToSubscribers(comments[0])

        # check if the update task has been enqueued
        self.assertTasksInQueue(n=1, url=self._taskUpdateUrl(task))
示例#9
0
 def createSubscribersForTask(self):
   """Creates subscribers for the task.
   """
   for i in range(4):
     email = '*****@*****.**' % str(i)
     subscriber = GCIProfileHelper(self.gci, self.dev_test)
     subscriber.createOtherUser(email)
     subscriber.createProfile()
     self.task.subscribers.append(subscriber.profile.key())
   self.task.put()
示例#10
0
 def createSubscribersForTask(self):
     """Creates subscribers for the task.
 """
     for i in range(4):
         email = "*****@*****.**" % str(i)
         subscriber = GCIProfileHelper(self.gci, self.dev_test)
         subscriber.createOtherUser(email)
         subscriber.createProfile()
         self.task.subscribers.append(subscriber.profile.key())
     self.task.put()
示例#11
0
    def createTask(self, status=None, org=None, mentor=None, student=None):
        if not mentor:
            profile_helper = GCIProfileHelper(self.gci, self.dev_test)
            mentor = profile_helper.createOtherUser(
                '*****@*****.**').createMentor(self.org)

        if not student:
            profile_helper = GCIProfileHelper(self.gci, self.dev_test)
            student = profile_helper.createOtherUser(
                '*****@*****.**').createStudent()

        if not org:
            org = self.org

        if not status:
            status = 'Open'

        gci_task_helper = GCITaskHelper(self.program)
        return gci_task_helper.createTask(status, org, mentor, student)
示例#12
0
  def createTask(self, status=None, org=None, mentor=None, student=None):
    if not mentor:
      profile_helper = GCIProfileHelper(self.gci, self.dev_test)
      mentor = profile_helper.createOtherUser(
          '*****@*****.**').createMentor(self.org)

    if not student:
      profile_helper = GCIProfileHelper(self.gci, self.dev_test)
      student = profile_helper.createOtherUser(
          '*****@*****.**').createStudent()

    if not org:
      org = self.org

    if not status:
      status = 'Open'

    gci_task_helper = GCITaskHelper(self.program)
    return gci_task_helper.createTask(status, org, mentor, student)
示例#13
0
    def setUp(self):
        """Creates a published task for self.org.
    """
        super(TaskViewTest, self).setUp()
        self.init()
        self.timeline.tasksPubliclyVisible()

        # Create a task, status published
        profile = GCIProfileHelper(self.gci, self.dev_test)
        self.task = profile.createOtherUser("*****@*****.**").createMentorWithTask("Open", self.org)
        self.createSubscribersForTask()
示例#14
0
  def setUp(self):
    """Creates a published task for self.org.
    """
    super(TaskViewTest, self).setUp()
    self.init()
    self.timeline.tasksPubliclyVisible()

    # Create a task, status published
    profile = GCIProfileHelper(self.gci, self.dev_test)
    self.task = profile.createOtherUser('*****@*****.**').\
        createMentorWithTask('Open', self.org)
    self.createSubscribersForTask()
示例#15
0
 def _invitee(self):
     invitee_data = GCIProfileHelper(self.gci, self.dev_test)
     invitee_data.createOtherUser("*****@*****.**")
     invitee_data.createProfile()
     invitee_data.notificationSettings(new_invites=True)
     return invitee_data.profile
示例#16
0
 def _invitee(self):
   invitee_data = GCIProfileHelper(self.gci, self.dev_test)
   invitee_data.createOtherUser('*****@*****.**')
   invitee_data.createProfile()
   invitee_data.notificationSettings(new_invites=True)
   return invitee_data.profile