当前位置: 首页>>代码示例>>Python>>正文


Python profile_utils.seedNDBProfile函数代码示例

本文整理汇总了Python中tests.profile_utils.seedNDBProfile函数的典型用法代码示例。如果您正苦于以下问题:Python seedNDBProfile函数的具体用法?Python seedNDBProfile怎么用?Python seedNDBProfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了seedNDBProfile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testAccessToTheList

  def testAccessToTheList(self):
    """Tests only the host can access the list."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    response = self.get(self.url)
    self.assertResponseForbidden(response)

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(
        self.program.key(), user=user,
        mentor_for=[ndb.Key.from_old_key(self.org.key())])

    response = self.get(self.url)
    self.assertResponseForbidden(response)

    # check for an organization administrator
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(
        self.program.key(), user=user,
        admin_for=[ndb.Key.from_old_key(self.org.key())])

    response = self.get(self.url)
    self.assertResponseForbidden(response)

    user = profile_utils.seedNDBUser(host_for=[self.program])
    profile_utils.loginNDB(user)
    response = self.get(self.url)
    self.assertResponseOK(response)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:32,代码来源:test_students_info.py

示例2: testPostButtonExtendDeadline

  def testPostButtonExtendDeadline(self):
    """Tests the extend deadline button."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(
        self.program.key(), user=user,
        mentor_for=[ndb.Key.from_old_key(self.org.key())])

    student = profile_utils.seedNDBStudent(self.program)

    # 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.key.to_old_key()
    self.task.deadline = deadline
    self.task.put()

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

    task = task_model.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.assertEqual(len(comments), 1)
    self.assertMailSentToSubscribers(comments[0])

    self.assertBasicTaskView()
开发者ID:rhyolight,项目名称:nupic.son,代码行数:34,代码来源:test_task.py

示例3: testPostButtonUnassign

  def testPostButtonUnassign(self):
    """Tests the unassign button."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(
        self.program.key(), user=user,
        mentor_for=[ndb.Key.from_old_key(self.org.key())])

    student = profile_utils.seedNDBStudent(self.program)

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

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

    # check if the task is properly unassigned
    task = task_model.GCITask.get(self.task.key())
    self.assertResponseRedirect(response)
    self.assertEqual(task.status, task_model.REOPENED)
    self.assertIsNone(task.student)
    self.assertIsNone(task.deadline)

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

    self.assertBasicTaskView()
开发者ID:rhyolight,项目名称:nupic.son,代码行数:30,代码来源:test_task.py

示例4: testPostButtonNeedsWork

  def testPostButtonNeedsWork(self):
    """Tests the needs more work for task button."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(
        self.program.key(), user=user,
        mentor_for=[ndb.Key.from_old_key(self.org.key())])

    student = profile_utils.seedNDBStudent(self.program)

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

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

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

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

    self.assertBasicTaskView()
开发者ID:rhyolight,项目名称:nupic.son,代码行数:32,代码来源:test_task.py

示例5: testOrgAppCreateOrEditByMentor

  def testOrgAppCreateOrEditByMentor(self):
    """Tests that a mentor cannot create an organization application.
    """
    # Make sure we do not have an org app for this test.
    self.org_app.delete()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(
        self.program.key(), user=user, mentor_for=[self.org.key])

    url = '/gsoc/org/application/edit/' + self.gsoc.key().name()
    response = self.get(url)
    self.assertResponseForbidden(response)

    org_app_key_name = 'gsoc_program/%s/orgapp' % (self.gsoc.key().name(),)
    org_app = org_app_survey.OrgAppSurvey.get_by_key_name(org_app_key_name)

    self.assertIsNone(org_app)

    response = self.post(url, self.getOrgAppCreatePostData())
    self.assertResponseForbidden(response)

    org_app = org_app_survey.OrgAppSurvey.get_by_key_name(org_app_key_name)
    self.assertIsNone(org_app)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:25,代码来源:test_org_app.py

示例6: testPostButtonAssign

  def testPostButtonAssign(self):
    """Tests the assign button."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(
        self.program.key(), user=user,
        mentor_for=[ndb.Key.from_old_key(self.org.key())])

    student = profile_utils.seedNDBStudent(self.program)

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

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

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

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

    # check if the update task has been enqueued
    self.assertTasksInQueue(n=1, url=_taskUpdateURL(task))

    self.assertBasicTaskView()
开发者ID:rhyolight,项目名称:nupic.son,代码行数:35,代码来源:test_task.py

示例7: testEmailIsSent

  def testEmailIsSent(self):
    """Tests that acceptance and rejection emails are sent."""
    # seed a couple of organization administrators for both organizations
    addresses_for_accept_email = []
    addresses_for_reject_email = []
    for _ in range(_NUMBER_OF_ORG_ADMINS):
      profile = profile_utils.seedNDBProfile(
          self.program.key(), admin_for=[self.pre_accepted_org.key])
      addresses_for_accept_email.append(profile.contact.email)

      profile = profile_utils.seedNDBProfile(
          self.program.key(), admin_for=[self.pre_rejected_org.key])
      addresses_for_reject_email.append(profile.contact.email)

    # finalize decision and execute all MapReduce jobs
    kwargs = {
        'sponsor': self.sponsor.key().name(),
        'program': self.program.program_id,
        }
    request = http.HttpRequest()
    data = request_data.RequestData(request, None, kwargs)

    handler = org_app_view.ApplyOrgAdmissionDecisionHandler(_MockView())
    handler.handle(data, None, None)

    self.executeMapReduceJobs()

    # check that emails have been sent
    for email_address in addresses_for_accept_email:
      self.assertEmailSent(bcc=email_address)

    for email_address in addresses_for_reject_email:
      self.assertEmailSent(bcc=email_address)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:33,代码来源:test_org_app.py

示例8: testForNonStudentProfile

  def testForNonStudentProfile(self):
    """Tests that True is returned if a non-student profile exists."""
    # seed a non-student profile
    profile_utils.seedNDBProfile(self.program.key(), user=self.user)

    result = validate.hasNonStudentProfileForProgram(
        self.user.key, self.program.key())
    self.assertTrue(result)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:8,代码来源:test_validate.py

示例9: testPageLoads

  def testPageLoads(self):
    """Tests that the page loads properly."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(self.program.key(), user=user)

    response = self.get(_getPickOrganizationToConnectUrl(self.program))
    self.assertResponseOK(response)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:8,代码来源:test_connection.py

示例10: testUserWithActiveProfileAccessGranted

  def testUserWithActiveProfileAccessGranted(self):
    """Tests that access is granted if the user has an active profile."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(self.program.key(), user=user)

    access_checker = access.HAS_PROFILE_ACCESS_CHECKER
    access_checker.checkAccess(self.data, None)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:8,代码来源:test_access.py

示例11: setUp

 def setUp(self):
   """See unittest.TestCase.setUp for specification."""
   program = program_utils.seedProgram()
   profile = profile_utils.seedNDBProfile(program.key())
   org = org_utils.seedOrganization(program.key())
   self.connection = connection_utils.seed_new_connection(profile.key, org.key)
   self.org_admin = profile_utils.seedNDBProfile(
       program.key(), admin_for=[org.key])
开发者ID:rhyolight,项目名称:nupic.son,代码行数:8,代码来源:test_connection.py

示例12: testPageLoads

  def testPageLoads(self):
    """Tests that the page loads properly."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(self.program.key(), user=user)

    response = self.get(_getNotificationSettingsUrl(self.program.key()))
    self.assertResponseOK(response)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:8,代码来源:test_notification_settings.py

示例13: testUserWithNonStudentProfileAccessGranted

  def testUserWithNonStudentProfileAccessGranted(self):
    """Tests that access is granted if current user has non-student profile."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(self.program.key(), user=user)

    access_checker = access.NON_STUDENT_PROFILE_ACCESS_CHECKER
    access_checker.checkAccess(self.data, None)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:8,代码来源:test_access.py

示例14: testPageLoads

  def testPageLoads(self):
    """Tests that page loads properly."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(self.program.key(), user=user)

    response = self.get(_getOrgProfileCreateUrl(self.program))
    self.assertResponseOK(response)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:8,代码来源:test_org_app.py

示例15: testOrgAdminAccessForbidden

  def testOrgAdminAccessForbidden(self):
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(
        self.program.key(), user=user, admin_for=[self.org.key])

    self._assertAccessForbiddenForUrl(self._getEnrollmentFormUrl())
    self._assertAccessForbiddenForUrl(self._getTaxFormUrl())
开发者ID:rhyolight,项目名称:nupic.son,代码行数:8,代码来源:test_student_forms.py


注:本文中的tests.profile_utils.seedNDBProfile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。