Esempio n. 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])
Esempio n. 2
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])
Esempio n. 3
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])
Esempio n. 4
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])
Esempio n. 5
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])
Esempio n. 6
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])
Esempio n. 7
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))
Esempio n. 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))
Esempio n. 9
0
  def testPostButtonDelete(self):
    """Tests the delete button.
    """
    self.data.createOrgAdmin(self.org)

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

    task = GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertEqual(task, None)
Esempio n. 10
0
    def testPostButtonUnpublish(self):
        """Tests the unpublish button.
    """
        self.data.createOrgAdmin(self.org)

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

        task = GCITask.get(self.task.key())
        self.assertResponseRedirect(response)
        self.assertEqual(task.status, "Unpublished")
Esempio n. 11
0
    def testPostButtonDelete(self):
        """Tests the delete button.
    """
        self.data.createOrgAdmin(self.org)

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

        task = GCITask.get(self.task.key())
        self.assertResponseRedirect(response)
        self.assertEqual(task, None)
Esempio n. 12
0
  def testPostButtonUnpublish(self):
    """Tests the unpublish button.
    """
    self.data.createOrgAdmin(self.org)

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

    task = GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertEqual(task.status, 'Unpublished')
Esempio n. 13
0
def convertGCITask(task_key):
  """Converts the specified task by changing values of its profile related
  properties to the new NDB based profile entities.

  Args:
    task_key: Task key.
  """
  task = GCITask.get(task_key)
  task.created_by = _convertReferenceProperty(GCITask.created_by, task)
  task.modified_by = _convertReferenceProperty(GCITask.modified_by, task)
  task.student = _convertReferenceProperty(GCITask.student, task)
  task.mentors = _convertListProperty(GCITask.mentors, task)
  task.subscribers = _convertListProperty(GCITask.subscribers, task)
  task.put()
Esempio n. 14
0
def convertGCITask(task_key):
    """Converts the specified task by changing values of its profile related
  properties to the new NDB based profile entities.

  Args:
    task_key: Task key.
  """
    task = GCITask.get(task_key)
    task.created_by = _convertReferenceProperty(GCITask.created_by, task)
    task.modified_by = _convertReferenceProperty(GCITask.modified_by, task)
    task.student = _convertReferenceProperty(GCITask.student, task)
    task.mentors = _convertListProperty(GCITask.mentors, task)
    task.subscribers = _convertListProperty(GCITask.subscribers, task)
    task.put()
Esempio n. 15
0
  def testPostButtonSubscribe(self):
    """Tests the subscribe button.
    """
    self.data.createMentor(self.org)

    profile = self.data.profile
    self.assertFalse(profile.key() in self.task.subscribers)

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

    task = GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertTrue(profile.key() in task.subscribers)
Esempio n. 16
0
    def testPostButtonSubscribe(self):
        """Tests the subscribe button.
    """
        self.data.createMentor(self.org)

        profile = self.data.profile
        self.assertFalse(profile.key() in self.task.subscribers)

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

        task = GCITask.get(self.task.key())
        self.assertResponseRedirect(response)
        self.assertTrue(profile.key() in task.subscribers)
Esempio n. 17
0
  def testPostButtonUnsubscribe(self):
    """Tests the unsubscribe button.
    """
    self.data.createMentor(self.org)

    # subscribe to the task manually
    profile = self.data.profile
    self.task.subscribers.append(profile.key())
    self.task.put()

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

    task = GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertFalse(profile.key() in task.subscribers)
Esempio n. 18
0
    def testPostButtonUnsubscribe(self):
        """Tests the unsubscribe button.
    """
        self.data.createMentor(self.org)

        # subscribe to the task manually
        profile = self.data.profile
        self.task.subscribers.append(profile.key())
        self.task.put()

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

        task = GCITask.get(self.task.key())
        self.assertResponseRedirect(response)
        self.assertFalse(profile.key() in task.subscribers)
Esempio n. 19
0
def process_tag(tag):
  """Replace all the references to the list of old tasks to the new tasks.
  """
  new_tagged_keys = []
  for t in tag.tagged:
    try:
      task = GCITask.get(t)
      new_tagged = new_task_for_old(task) if task else None
    except db.KindError:
      new_tagged = t

    if new_tagged:
      new_tagged_keys.append(new_tagged)

  tag.tagged = new_tagged_keys

  yield operation.db.Put(tag)
  yield operation.counters.Increment("tag_updated")
Esempio n. 20
0
  def testPostButtonClaim(self):
    """Tests the claim task button.
    """
    self.data.createStudent()

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

    # check if the task is properly claimed
    task = GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertEqual(task.status, 'ClaimRequested')
    self.assertEqual(task.student.key(), self.data.profile.key())

    # check if a comment has been created
    comments = self.task.comments()
    self.assertLength(comments, 1)
    self.assertMailSentToSubscribers(comments[0])
Esempio n. 21
0
    def testPostButtonClaim(self):
        """Tests the claim task button.
    """
        self.data.createStudent()

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

        # check if the task is properly claimed
        task = GCITask.get(self.task.key())
        self.assertResponseRedirect(response)
        self.assertEqual(task.status, "ClaimRequested")
        self.assertEqual(task.student.key(), self.data.profile.key())

        # check if a comment has been created
        comments = self.task.comments()
        self.assertLength(comments, 1)
        self.assertMailSentToSubscribers(comments[0])
Esempio n. 22
0
    def testPostSendForReview(self):
        """Tests for submitting work.
    """
        self.data.createStudent()

        self.task.status = "Claimed"
        self.task.student = self.data.profile
        # set deadline to far future
        self.task.deadline = datetime.datetime.utcnow() + datetime.timedelta(days=1)
        self.task.put()

        GCITaskHelper(self.program).createWorkSubmission(self.task, self.data.profile)

        url = "%s?send_for_review" % self._taskPageUrl(self.task)
        response = self.post(url)

        task = GCITask.get(self.task.key())
        self.assertResponseRedirect(response)
        self.assertEqual(task.status, "NeedsReview")
Esempio n. 23
0
  def testPostSendForReview(self):
    """Tests for submitting work.
    """
    self.data.createStudent()

    self.task.status = 'Claimed'
    self.task.student = self.data.profile
    # set deadline to far future
    self.task.deadline = datetime.datetime.utcnow() + datetime.timedelta(days=1)
    self.task.put()

    GCITaskHelper(self.program).createWorkSubmission(
        self.task, self.data.profile)

    url = '%s?send_for_review' %self._taskPageUrl(self.task)
    response = self.post(url)

    task = GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertEqual(task.status, 'NeedsReview')
 def subscribe_to_task_txn(task_key, subscribe):
     task = GCITask.get(task_key)
     task.subscribers = list(set(task.subscribers + subscribe))
     task.put()
     return task
 def subscribe_to_task_txn(task_key, subscribe):
     task = GCITask.get(task_key)
     task.subscribers = list(set(task.subscribers + subscribe))
     task.put()
     return task