Beispiel #1
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])
Beispiel #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])
Beispiel #3
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])
Beispiel #4
0
    def testStudentsInfoList(self):
        """Tests the studentsInfoList component of the dashboard.
    """
        student = GCIProfileHelper(
            self.gci,
            self.dev_test).createOtherUser('*****@*****.**').createStudent()
        info = student.student_info
        #We do this because currently the seeder can not seed the
        #BlobReference properties. What we do below is not correct in practice, but
        #is ok for testing purpose.
        consent_form = blobstore.BlobKey(
            'I cant allow u to participate in GCI :P')
        info.consent_form = consent_form
        info.put()

        score_properties = {
            'points': 5,
            'program': self.gci,
            'parent': student
        }
        score = GCIScore(**score_properties)
        score.put()

        idx = 1
        #Set the current user to be the host.
        self.data.createHost()
        response = self.get(self.url)
        self.assertStudentsInfoTemplatesUsed(response)

        response = self.getListResponse(self.url, idx)
        self.assertIsJsonResponse(response)

        data = self.getListData(self.url, idx)
        self.assertEqual(len(data), 1)

        #Only the consent form has been submitted.
        self.assertEqual(data[0]['columns']['consent_form'], 'Yes')
        self.assertEqual(data[0]['columns']['student_id_form'], 'No')

        #Case when both the forms have been submitted.
        student_id_form = blobstore.BlobKey('student_id')
        info.student_id_form = student_id_form
        info.put()
        data = self.getListData(self.url, idx)
        self.assertEqual(len(data), 1)
        self.assertEqual(data[0]['columns']['consent_form'], 'Yes')
        self.assertEqual(data[0]['columns']['student_id_form'], 'Yes')

        #Case when none of the two forms have been submitted.
        info.consent_form = None
        info.student_id_form = None
        info.put()
        data = self.getListData(self.url, idx)
        self.assertEqual(len(data), 1)
        list_fields = data[0]['columns']
        self.assertEqual(list_fields['consent_form'], 'No')
        self.assertEqual(list_fields['student_id_form'], 'No')
        self.assertEqual(list_fields['name'], student.name())
        self.assertEqual(list_fields['link_id'], student.link_id)
        self.assertEqual(list_fields['email'], student.email)
Beispiel #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])
Beispiel #6
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))
Beispiel #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])
Beispiel #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))
Beispiel #9
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])
Beispiel #10
0
  def testStudentsInfoList(self):
    """Tests the studentsInfoList component of the dashboard.
    """
    student = GCIProfileHelper(self.gci, self.dev_test).createOtherUser(
        '*****@*****.**').createStudent()
    info = student.student_info
    #We do this because currently the seeder can not seed the
    #BlobReference properties. What we do below is not correct in practice, but
    #is ok for testing purpose. 
    consent_form = blobstore.BlobKey('I cant allow u to participate in GCI :P')
    info.consent_form = consent_form
    info.put() 
    
    score_properties = {'points': 5, 'program': self.gci, 'parent': student}
    score = GCIScore(**score_properties)
    score.put()

    
    idx = 1
    #Set the current user to be the host.
    self.data.createHost()
    response = self.get(self.url)
    #print response
    self.assertStudentsInfoTemplatesUsed(response)
    response = self.getListResponse(self.url, idx)
    #print response
    
    self.assertIsJsonResponse(response)
    
    data = self.getListData(self.url, idx)
    #print data
    self.assertEqual(len(data), 1)
    #Only the consent form has been submitted.
    self.assertEqual(data[0]['columns']['consent_form'], 'Yes')
    self.assertEqual(data[0]['columns']['student_id_form'], 'No')
    
    #Case when both the forms have been submitted.
    student_id_form = blobstore.BlobKey('student_id')
    info.student_id_form = student_id_form
    info.put()
    data = self.getListData(self.url, idx)
    self.assertEqual(len(data), 1)
    self.assertEqual(data[0]['columns']['consent_form'], 'Yes')
    self.assertEqual(data[0]['columns']['student_id_form'], 'Yes')
    
    #Case when none of the two forms are submitted.
    info.consent_form = None
    info.student_id_form = None
    info.put()
    data = self.getListData(self.url, idx)
    self.assertEqual(len(data), 1)
    list_fields = data[0]['columns']
    self.assertEqual(list_fields['consent_form'], 'No')
    self.assertEqual(list_fields['student_id_form'], 'No')
    self.assertEqual(list_fields['name'], student.name())
    self.assertEqual(list_fields['link_id'], student.link_id)
    self.assertEqual(list_fields['email'], student.email)
Beispiel #11
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()
Beispiel #12
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()
Beispiel #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()
Beispiel #14
0
  def testCreateTaskAfterClaimEndForStudent(self):
    """Tests the task creation view after the task claim deadline for student.
    """
    self.timeline.taskClaimEnded()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createStudent()

    url = '/gci/task/create/' + self.org.key().name()
    response = self.get(url)

    # Task creation has not started yet
    self.assertResponseForbidden(response)
Beispiel #15
0
  def testCreateTaskDuringProgramForStudent(self):
    """Tests the task creation view during the program for org admin.
    """
    self.timeline.tasksPubliclyVisible()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createStudent()

    url = '/gci/task/create/' + self.org.key().name()
    response = self.get(url)

    # Student can't create tasks
    self.assertResponseForbidden(response)
    def testCreateTaskBeforeOrgsAnnouncedForOrgAdmin(self):
        """Tests the task creation view before the program is public for org admin.
    """
        self.timeline.orgSignup()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createOrgAdmin(self.org)

        url = '/gci/task/create/' + self.org.key().name()
        response = self.get(url)

        # Task creation has not started yet
        self.assertResponseForbidden(response)
    def testCreateTaskDuringProgramForNoRole(self):
        """Tests the task creation view during the program for user with no role.
    """
        self.timeline.tasksPubliclyVisible()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createProfile()

        url = '/gci/task/create/' + self.org.key().name()
        response = self.get(url)

        # User has no privileges to create tasks
        self.assertResponseForbidden(response)
Beispiel #18
0
  def testCreateTaskBeforeOrgsAnnouncedForOrgAdmin(self):
    """Tests the task creation view before the program is public for org admin.
    """
    self.timeline.orgSignup()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createOrgAdmin(self.org)

    url = '/gci/task/create/' + self.org.key().name()
    response = self.get(url)

    # Task creation has not started yet
    self.assertResponseForbidden(response)
    def testCreateTaskDuringProgramForMentor(self):
        """Tests the task creation view during the program for org admin.
    """
        self.timeline.tasksPubliclyVisible()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createMentor(self.org)

        url = '/gci/task/create/' + self.org.key().name()
        response = self.get(url)

        self.assertResponseOK(response)
        self.assertFullEditTemplatesUsed(response)
    def testCreateTaskDuringProgramForStudent(self):
        """Tests the task creation view during the program for org admin.
    """
        self.timeline.tasksPubliclyVisible()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createStudent()

        url = '/gci/task/create/' + self.org.key().name()
        response = self.get(url)

        # Student can't create tasks
        self.assertResponseForbidden(response)
Beispiel #21
0
  def testCreateTaskDuringProgramForNoRole(self):
    """Tests the task creation view during the program for user with no role.
    """
    self.timeline.tasksPubliclyVisible()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createProfile()

    url = '/gci/task/create/' + self.org.key().name()
    response = self.get(url)

    # User has no privileges to create tasks
    self.assertResponseForbidden(response)
Beispiel #22
0
  def testCreateTaskDuringProgramForMentor(self):
    """Tests the task creation view during the program for org admin.
    """
    self.timeline.tasksPubliclyVisible()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createMentor(self.org)

    url = '/gci/task/create/' + self.org.key().name()
    response = self.get(url)

    self.assertResponseOK(response)
    self.assertFullEditTemplatesUsed(response)
    def testCreateTaskAfterClaimEndForStudent(self):
        """Tests the task creation view after the task claim deadline for student.
    """
        self.timeline.taskClaimEnded()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createStudent()

        url = '/gci/task/create/' + self.org.key().name()
        response = self.get(url)

        # Task creation has not started yet
        self.assertResponseForbidden(response)
Beispiel #24
0
  def testPostClaimEditTaskDuringProgramForMentor(self):
    """Tests the task post claim editing view during the program for mentor.
    """
    self.timeline.tasksPubliclyVisible()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createMentor(self.org)

    task = self.createTask(status='NeedsReview')

    url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
    response = self.get(url)

    self.assertResponseOK(response)
    self.assertPostClaimEditTemplatesUsed(response)
Beispiel #25
0
  def testFullEditTaskDuringProgramForOrgAdmin(self):
    """Tests the task full editing view during the program for org admin.
    """
    self.timeline.tasksPubliclyVisible()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createOrgAdmin(self.org)

    task = self.createTask('Reopened')

    url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
    response = self.get(url)

    self.assertResponseOK(response)
    self.assertPostClaimEditTemplatesUsed(response)
    def testPostClaimEditTaskDuringProgramForStudent(self):
        """Tests the task post claim editing view during the program for student.
    """
        self.timeline.tasksPubliclyVisible()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createStudent()

        task = self.createTask(status='ActionNeeded')

        url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
        response = self.get(url)

        # Student cannot edit task
        self.assertResponseForbidden(response)
    def testPostClaimEditTaskDuringProgramForMentor(self):
        """Tests the task post claim editing view during the program for mentor.
    """
        self.timeline.tasksPubliclyVisible()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createMentor(self.org)

        task = self.createTask(status='NeedsReview')

        url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
        response = self.get(url)

        self.assertResponseOK(response)
        self.assertPostClaimEditTemplatesUsed(response)
Beispiel #28
0
  def testPostClaimEditTaskDuringProgramForStudent(self):
    """Tests the task post claim editing view during the program for student.
    """
    self.timeline.tasksPubliclyVisible()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createStudent()

    task = self.createTask(status='ActionNeeded')

    url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
    response = self.get(url)

    # Student cannot edit task
    self.assertResponseForbidden(response)
    def testFullEditTaskDuringProgramForOrgAdmin(self):
        """Tests the task full editing view during the program for org admin.
    """
        self.timeline.tasksPubliclyVisible()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createOrgAdmin(self.org)

        task = self.createTask('Reopened')

        url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
        response = self.get(url)

        self.assertResponseOK(response)
        self.assertPostClaimEditTemplatesUsed(response)
    def testPostClaimEditTaskDuringProgramForNoRole(self):
        """Tests the task post claim editing view during the program for user
    with no role.
    """
        self.timeline.tasksPubliclyVisible()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createProfile()

        task = self.createTask(status='ClaimRequested')

        url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
        response = self.get(url)

        # User without any role cannot edit the task
        self.assertResponseForbidden(response)
Beispiel #31
0
    def init(self):
        """Performs test setup.

    Sets the following attributes:
      program_helper: a GCIProgramHelper instance
      gci/program: a GCIProgram instance
      site: a Site instance
      org: a GCIOrganization instance
      org_app: a OrgAppSurvey instance
      timeline: a GCITimelineHelper instance
      data: a GCIProfileHelper instance
    """
        from tests.program_utils import GCIProgramHelper
        from tests.timeline_utils import GCITimelineHelper
        from tests.profile_utils import GCIProfileHelper
        super(GCITestCase, self).init()
        self.program_helper = GCIProgramHelper()
        self.founder = self.program_helper.createFounder()
        self.sponsor = self.program_helper.createSponsor()
        self.gci = self.program = self.program_helper.createProgram()
        self.site = self.program_helper.createSite()
        self.org = self.program_helper.createOrg()
        self.org_app = self.program_helper.createOrgApp()
        self.timeline = GCITimelineHelper(self.gci.timeline, self.org_app)
        self.data = GCIProfileHelper(self.gci, self.dev_test)
Beispiel #32
0
  def testPostClaimEditTaskAfterClaimEndForStudent(self):
    """Tests the task post claim editing view after the task claim deadline
    for student.
    """
    self.timeline.taskClaimEnded()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createStudent()

    task = self.createTask(status='ClaimRequested')

    url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
    response = self.get(url)

    # Task post claim editing has not started yet
    self.assertResponseForbidden(response)
    def testPostClaimEditTaskAfterClaimEndForStudent(self):
        """Tests the task post claim editing view after the task claim deadline
    for student.
    """
        self.timeline.taskClaimEnded()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createStudent()

        task = self.createTask(status='ClaimRequested')

        url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
        response = self.get(url)

        # Task post claim editing has not started yet
        self.assertResponseForbidden(response)
Beispiel #34
0
  def testPostClaimEditTaskAfterClaimEndForNoRole(self):
    """Tests the task post claim editing view after the task claim deadline for
    user with no role.
    """
    self.timeline.taskClaimEnded()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createProfile()

    task = self.createTask(status='NeedsReview')

    url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
    response = self.get(url)

    # Task post claim editing has not started yet and no role to edit tasks
    self.assertResponseForbidden(response)
Beispiel #35
0
  def testPostClaimEditTaskDuringProgramForNoRole(self):
    """Tests the task post claim editing view during the program for user
    with no role.
    """
    self.timeline.tasksPubliclyVisible()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createProfile()

    task = self.createTask(status='ClaimRequested')

    url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
    response = self.get(url)

    # User without any role cannot edit the task
    self.assertResponseForbidden(response)
    def testPostClaimEditTaskAfterClaimEndForNoRole(self):
        """Tests the task post claim editing view after the task claim deadline for
    user with no role.
    """
        self.timeline.taskClaimEnded()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createProfile()

        task = self.createTask(status='NeedsReview')

        url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
        response = self.get(url)

        # Task post claim editing has not started yet and no role to edit tasks
        self.assertResponseForbidden(response)
    def testPostClaimEditTaskBeforeOrgsAnnouncedForStudent(self):
        """Tests the task post claim editing view before the program is
    public for student.
    """
        self.timeline.orgSignup()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createStudent()

        task = self.createTask(status='NeedsWork')

        url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
        response = self.get(url)

        # Task post claim editing has not started yet
        self.assertResponseForbidden(response)
Beispiel #38
0
  def testPostClaimEditTaskBeforeOrgsAnnouncedForStudent(self):
    """Tests the task post claim editing view before the program is
    public for student.
    """
    self.timeline.orgSignup()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createStudent()

    task = self.createTask(status='NeedsWork')

    url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
    response = self.get(url)

    # Task post claim editing has not started yet
    self.assertResponseForbidden(response)
Beispiel #39
0
    def testGetOrCreateForStudent(self):
        """Tests if an appropriate ranking object is created for a student.
    """
        #There is no GCIStudentRanking object for self.student in the datastore.
        #Hence, a new entity should be created and returned.
        q = GCIStudentRanking.all()
        q.filter('student', self.student)
        ranking = q.get()

        self.assertEqual(ranking, None)

        actual_ranking = ranking_logic.getOrCreateForStudent(self.student)
        q = GCIStudentRanking.all()
        q.filter('student', self.student)
        expected_ranking = q.get()
        self.assertEqual(expected_ranking.key(), actual_ranking.key())

        #GCIStudentRanking object already exists for a student.
        student = GCIProfileHelper(
            self.program,
            False).createOtherUser('*****@*****.**').createStudent()
        ranking = GCIStudentRanking(program=student.scope, student=student)
        ranking.put()
        actual_ranking = ranking_logic.getOrCreateForStudent(student)

        self.assertEqual(ranking.key(), actual_ranking.key())
Beispiel #40
0
  def testFullEditTaskBeforeOrgsAnnouncedForMentor(self):
    """Tests the task full editing view before the program is public
    for mentor.
    """
    self.timeline.orgSignup()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createMentor(self.org)

    task = self.createTask()

    url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
    response = self.get(url)

    # Task full editing has not started yet
    self.assertResponseForbidden(response)
Beispiel #41
0
  def testPostClaimEditTaskBeforeOrgsAnnouncedForNoRole(self):
    """Tests the task post claim editing view before the program is public
    for user with no role.
    """
    self.timeline.orgSignup()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createProfile()

    task = self.createTask(status='ClaimRequested')

    url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
    response = self.get(url)

    # Task post claim editing has not started yet and no role to edit tasks
    self.assertResponseForbidden(response)
Beispiel #42
0
  def testFullEditTaskAfterClaimEndForMentor(self):
    """Tests the task full editing view after the task claim deadline for
    mentor.
    """
    self.timeline.taskClaimEnded()

    task = self.createTask()

    profile_helper = GCIProfileHelper(self.gci, self.dev_test)
    profile_helper.createMentor(self.org)

    url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
    response = self.get(url)

    # Task full editing has not started yet
    self.assertResponseForbidden(response)
    def testPostClaimEditTaskBeforeOrgsAnnouncedForNoRole(self):
        """Tests the task post claim editing view before the program is public
    for user with no role.
    """
        self.timeline.orgSignup()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createProfile()

        task = self.createTask(status='ClaimRequested')

        url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
        response = self.get(url)

        # Task post claim editing has not started yet and no role to edit tasks
        self.assertResponseForbidden(response)
    def testFullEditTaskBeforeOrgsAnnouncedForMentor(self):
        """Tests the task full editing view before the program is public
    for mentor.
    """
        self.timeline.orgSignup()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createMentor(self.org)

        task = self.createTask()

        url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
        response = self.get(url)

        # Task full editing has not started yet
        self.assertResponseForbidden(response)
    def testFullEditTaskAfterClaimEndForMentor(self):
        """Tests the task full editing view after the task claim deadline for
    mentor.
    """
        self.timeline.taskClaimEnded()

        task = self.createTask()

        profile_helper = GCIProfileHelper(self.gci, self.dev_test)
        profile_helper.createMentor(self.org)

        url = '/gci/task/edit/%s/%s' % (self.gci.key().name(), task.key().id())
        response = self.get(url)

        # Task full editing has not started yet
        self.assertResponseForbidden(response)
Beispiel #46
0
    def testOrgAppSurveyTakePage(self):
        """Tests organizationn application survey take/retake page.
    """
        self.updateOrgAppSurvey()

        self.data.createOrgAdmin(self.org)
        backup_admin = GCIProfileHelper(self.gci, self.dev_test)
        backup_admin.createMentor(self.org)

        response = self.get(self.take_url)
        self.assertTemplatesUsed(response)

        params = {
            'admin_id': self.data.user.link_id,
            'backup_admin_id': backup_admin.user.link_id
        }
        params.update(self.post_params)
        response = self.post(self.take_url, params)
        query = OrgAppRecord.all()
        query.filter('main_admin = ', self.data.user)
        self.assertEqual(query.count(), 1, 'Survey record is not created.')

        record = query.get()
        self.assertEqual(record.org_id, self.post_params['org_id'])
        self.assertEqual(record.name, self.post_params['name'])
        self.assertEqual(record.description, self.post_params['description'])
        self.assertEqual(record.license, self.post_params['license'])
        self.assertEqual(record.main_admin.key(), self.data.user.key())
        self.assertEqual(record.backup_admin.key(), backup_admin.user.key())

        retake_url = self.retake_url_raw % (self.gci.key().name(),
                                            record.key().id())
        self.assertResponseRedirect(response, retake_url + '?validated')

        response = self.get(retake_url)
        self.assertResponseOK(response)

        params = {'backup_admin_id': backup_admin.user.link_id}
        params.update(self.post_params)
        params['name'] = 'New title'

        response = self.post(retake_url, params)
        self.assertResponseRedirect(response, retake_url + '?validated')
        record = OrgAppRecord.get_by_id(record.key().id())
        self.assertEqual(record.name, params['name'])
Beispiel #47
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)
Beispiel #48
0
  def testOrgAppSurveyTakePage(self):
    """Tests organizationn application survey take/retake page.
    """
    self.updateOrgAppSurvey()

    self.data.createOrgAdmin(self.org)
    backup_admin = GCIProfileHelper(self.gci, self.dev_test)
    backup_admin.createMentor(self.org)

    response = self.get(self.take_url)
    self.assertTemplatesUsed(response)

    params = {'admin_id': self.data.user.link_id,
              'backup_admin_id': backup_admin.user.link_id}
    params.update(self.post_params)
    response = self.post(self.take_url, params)
    query = OrgAppRecord.all()
    query.filter('main_admin = ', self.data.user)
    self.assertEqual(query.count(), 1, 'Survey record is not created.')

    record = query.get()
    self.assertEqual(record.org_id, self.post_params['org_id'])
    self.assertEqual(record.name, self.post_params['name'])
    self.assertEqual(record.description, self.post_params['description'])
    self.assertEqual(record.license, self.post_params['license'])
    self.assertEqual(record.main_admin.key(), self.data.user.key())
    self.assertEqual(record.backup_admin.key(), backup_admin.user.key())

    retake_url = self.retake_url_raw % (self.gci.key().name(),
                                        record.key().id())
    self.assertResponseRedirect(response, retake_url + '?validated')

    response = self.get(retake_url)
    self.assertResponseOK(response)

    params = {'backup_admin_id': backup_admin.user.link_id}
    params.update(self.post_params)
    params['name'] = 'New title'

    response = self.post(retake_url, params)
    self.assertResponseRedirect(response, retake_url + '?validated')
    record = OrgAppRecord.get_by_id(record.key().id())
    self.assertEqual(record.name, params['name'])
  def testGetRemainingTaskQuota(self):
    """Tests if the remaining task quota that can be published by a given 
    organization is correctly returned.
    """
    gci_program_helper = GCIProgramHelper()
    org = gci_program_helper.createOrg()
    org.task_quota_limit = 5
    org.put()
    
    mentor = GCIProfileHelper(self.program, False).createOtherUser(
        '*****@*****.**').createMentor(org)
    
    student = GCIProfileHelper(self.program, False).createOtherUser(
        '*****@*****.**').createStudent()
    #valid tasks.
    for _ in xrange(3):
      self.task_helper.createTask('Closed', org, mentor, student)
    #invalid tasks.
    self.task_helper.createTask('Unpublished', org, mentor, student)
    expected_quota = org.task_quota_limit - 3
    actual_quota = organization_logic.getRemainingTaskQuota(org)

    self.assertEqual(expected_quota, actual_quota)
Beispiel #50
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()
    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)
Beispiel #52
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
Beispiel #53
0
 def setUp(self):
     self.gci_program_helper = GCIProgramHelper()
     self.program = self.gci_program_helper.createProgram()
     self.task_helper = GCITaskHelper(self.program)
     self.student = GCIProfileHelper(self.program, False).createStudent()
Beispiel #54
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