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


Python profile_utils.loginNDB函数代码示例

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


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

示例1: testStudentCannotAccess

  def testStudentCannotAccess(self):
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    response = self.get(self.url)
    self.assertErrorTemplatesUsed(response)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:7,代码来源:test_org_score.py

示例2: testCleanHtmlContent

 def testCleanHtmlContent(self):
   """Tests that html content can be cleaned.
   """
   field_name = 'test_html'
   clean_field = cleaning.clean_html_content(field_name)
   # Test that normal html can be cleaned
   expected = html = '<div>[email protected]</div>'
   self.form.cleaned_data = {field_name: html}
   self.assertEqual(clean_field(self.form), expected)
   # Test that normal html can be cleaned
   html = '<html>[email protected]</html>'
   self.form.cleaned_data = {field_name: html}
   expected = html.replace('<', '&lt;').replace('>', '&gt;')
   actual = clean_field(self.form)
   self.assertEqual(actual, expected)
   expected = html = u'\ua000'
   self.form.cleaned_data = {field_name: html}
   self.assertEqual(clean_field(self.form), expected)
   # Test that input with scripts will be encoded as well
   html = '<script></script>'
   self.form.cleaned_data = {field_name: html}
   actual = clean_field(self.form)
   expected = html.replace('<', '&lt;').replace('>', '&gt;')
   self.assertEqual(actual, expected)
   # Test that input can contain scripts when the current user is a developer
   profile_utils.loginNDB(self.user, is_admin=True)
   expected = html = '<script></script>'
   self.form.cleaned_data = {field_name: html}
   self.assertEqual(clean_field(self.form), expected)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:29,代码来源:test_cleaning.py

示例3: testStudentAccessForbidden

  def testStudentAccessForbidden(self):
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    response = self.get(self._getUrl())
    self.assertErrorTemplatesUsed(response)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:7,代码来源:test_program.py

示例4: testLoneUserAccessDenied

  def testLoneUserAccessDenied(self):
    """Tests that users without profiles cannot access the page."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)

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

示例5: testListProposals

  def testListProposals(self):
    user = profile_utils.seedNDBUser(host_for=[self.program])
    profile_utils.loginNDB(user)

    self.timeline_helper.studentSignup()

    url = '/gsoc/admin/proposals/' + self.org.key.id()
    response = self.get(url)
    self.assertResponseOK(response)
    self.assertProposalsPage(response)

    response = self.getListResponse(url, 0)
    self.assertIsJsonResponse(response)
    data = response.context['data']['']
    self.assertEqual(0, len(data))

    # test list with student's proposal
    student = profile_utils.seedSOCStudent(self.program)
    proposal_utils.seedProposal(
        student.key, self.program.key(), org_key=self.org.key)

    response = self.getListResponse(url, 0)
    self.assertIsJsonResponse(response)
    data = response.context['data']['']
    self.assertEqual(1, len(data))
开发者ID:rhyolight,项目名称:nupic.son,代码行数:25,代码来源:test_admin.py

示例6: testResubmitProposal

  def testResubmitProposal(self):
    self.timeline_helper.studentSignup()

    mentor = profile_utils.seedNDBProfile(
        self.program.key(), mentor_for=[self.org.key])
    # TODO(daniel): take care of notifications: notify_proposal_updates=True

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedSOCStudent(self.program, user)
    proposal = proposal_utils.seedProposal(
        student.key, self.program.key(), org_key=self.org.key,
        mentor_key=mentor.key, status=proposal_model.STATUS_WITHDRAWN)

    # TODO(daniel): take care of notifications
    # self.profile_helper.notificationSettings()

    url = '/gsoc/proposal/update/%s/%s/%s' % (
        self.gsoc.key().name(), student.profile_id, proposal.key().id())

    # resubmit proposal
    postdata = {'action': 'Resubmit'}
    self.post(url, postdata)

    # check if the proposal is resubmitted
    proposal = proposal_model.GSoCProposal.get(proposal.key())
    self.assertEqual(proposal_model.STATUS_PENDING, proposal.status)

    student = student.key.get()
    # check if number of proposals is increased
    self.assertEqual(student.student_data.number_of_proposals, 1)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:31,代码来源:test_proposal.py

示例7: testPostPublish

  def testPostPublish(self):
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile = profile_utils.seedNDBProfile(
        self.program.key(), user=user,
        admin_for=[ndb.Key.from_old_key(self.org.key())])

    # check if Unpublished task may be published
    self._testPostPublish(profile, 'Unpublished', 'Open', 'publish')

    # check if Unapproved task may be published
    self._testPostPublish(profile, task_model.UNAPPROVED, 'Open', 'publish')

    # check if Open task may be unpublished
    self._testPostPublish(profile, 'Open', 'Unpublished', 'unpublish')

    # check if Reopened task may not be changed
    self._testPostPublish(
        profile, task_model.REOPENED, task_model.REOPENED, 'publish')
    self._testPostPublish(
        profile, task_model.REOPENED, task_model.REOPENED, 'unpublish')

    # check if Claimed task may not be changed
    self._testPostPublish(profile, 'Claimed', 'Claimed', 'publish')
    self._testPostPublish(profile, 'Claimed', 'Claimed', 'unpublish')

    # check if ActionNeeded task may not be changed
    self._testPostPublish(profile, 'ActionNeeded', 'ActionNeeded', 'publish')
    self._testPostPublish(profile, 'ActionNeeded', 'ActionNeeded', 'unpublish')

    # check if Closed task may not be changed
    self._testPostPublish(profile, 'Closed', 'Closed', 'publish')
    self._testPostPublish(profile, 'Closed', 'Closed', 'unpublish')
开发者ID:rhyolight,项目名称:nupic.son,代码行数:33,代码来源:test_dashboard.py

示例8: testSubmitAnotherForm

  def testSubmitAnotherForm(self):
    """Tests that another form may be resubmitted by a student."""
    self.timeline_helper.formSubmission()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedSOCStudent(self.program, user=user)
    project_utils.seedProject(
        student, self.program.key(), org_key=self.org.key)

    # set initial tax form
    blob_key = self.createBlob('initial_tax_form.pdf')
    student.student_data.tax_form = blob_key
    student.put()

    # submit a new tax form
    with tempfile.NamedTemporaryFile() as test_file:
      # check for the enrollment form
      url = self._getTaxFormUrl()
      postdata = {'tax_form': test_file}
      response = self.post(url, postdata)
      self.assertResponseRedirect(
          response, self._getTaxFormUrl(validated=True))

      # check if the form has been submitted
      student = student.key.get()
      self.assertIsNotNone(student.student_data.tax_form)
      self.assertEqual(os.path.basename(test_file.name),
          student.student_data.tax_form)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:29,代码来源:test_student_forms.py

示例9: testDashboardAsStudentWithEval

  def testDashboardAsStudentWithEval(self):
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile = profile_utils.seedNDBStudent(self.program, user=user)

    project_utils.seedProject(profile, self.program.key())

    url = '/gsoc/dashboard/' + self.gsoc.key().name()
    response = self.get(url)
    self.assertResponseOK(response)
    self.assertDashboardComponentTemplatesUsed(response)
    response = self.getListResponse(url, 3)
    self.assertResponseForbidden(response)

    response = self.get(url)
    self.assertResponseOK(response)
    self.assertDashboardComponentTemplatesUsed(response)
    self.evaluation = SurveyHelper(self.gsoc, self.dev_test)
    self.evaluation.createStudentEvaluation(override={'link_id': 'midterm'})
    response = self.getListResponse(url, 3)
    self.assertIsJsonResponse(response)
    data = json.loads(response.content)
    self.assertEqual(len(data['data']['']), 1)

    self.evaluation.createStudentEvaluation(override={'link_id': 'final'})
    response = self.getListResponse(url, 3)
    self.assertIsJsonResponse(response)
    data = json.loads(response.content)
    self.assertEqual(len(data['data']['']), 2)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:29,代码来源:test_dashboard.py

示例10: testDashboardAsStudent

  def testDashboardAsStudent(self):
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

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

示例11: testAcceptProposal

  def testAcceptProposal(self):
    """Tests that a proposal is correctly accepted."""
    user = profile_utils.seedNDBUser(host_for=[self.program])
    profile_utils.loginNDB(user)

    mentor = profile_utils.seedNDBProfile(
        self.program.key(), mentor_for=[self.org.key])
    student = profile_utils.seedNDBStudent(self.program)
    proposal = proposal_utils.seedProposal(
        student.key, self.program.key(), org_key=self.org.key,
        mentor_key=mentor.key)

    list_data = [{accept_withdraw_projects._PROPOSAL_KEY: str(proposal.key())}]
    post_data = {
        'button_id': 'accept',
        'data': json.dumps(list_data),
        'idx': 0,
        }
    self.post(self.url, post_data)

    # check if proposal is accepted correctly
    proposal = proposal_model.GSoCProposal.get(proposal.key())
    self.assertEqual(proposal.status, proposal_model.STATUS_ACCEPTED)

    # check if a project is created
    project = project_model.GSoCProject.all().ancestor(
        student.key.to_old_key()).get()
    self.assertEqual(project.status, project_model.STATUS_ACCEPTED)
    self.assertEqual(project.proposal.key(), proposal.key())

    # check if number of projects is updated
    student = student.key.get()
    self.assertEqual(student.student_data.number_of_projects, 1)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:33,代码来源:test_accept_withdraw_projects.py

示例12: testAcceptTwoProposals

  def testAcceptTwoProposals(self):
    """Tests that two proposals can be accepted in the same request."""
    user = profile_utils.seedNDBUser(host_for=[self.program])
    profile_utils.loginNDB(user)

    mentor = profile_utils.seedNDBProfile(
        self.program.key(), mentor_for=[self.org.key])

    student_one = profile_utils.seedNDBStudent(self.program)
    proposal_one = proposal_utils.seedProposal(
        student_one.key, self.program.key(), org_key=self.org.key,
        mentor_key=mentor.key)
    student_two = profile_utils.seedNDBStudent(self.program)
    proposal_two = proposal_utils.seedProposal(
        student_two.key, self.program.key(), org_key=self.org.key,
        mentor_key=mentor.key)

    list_data = [
        {accept_withdraw_projects._PROPOSAL_KEY: str(proposal_one.key())},
        {accept_withdraw_projects._PROPOSAL_KEY: str(proposal_two.key())}
        ]

    post_data = {
        'button_id': 'accept',
        'data': json.dumps(list_data),
        'idx': 0,
        }
    self.post(self.url, post_data)

    # check if both proposals are accepted correctly
    proposal1 = proposal_model.GSoCProposal.get(proposal_one.key())
    self.assertEqual(proposal1.status, proposal_model.STATUS_ACCEPTED)

    proposal2 = proposal_model.GSoCProposal.get(proposal_two.key())
    self.assertEqual(proposal2.status, proposal_model.STATUS_ACCEPTED)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:35,代码来源:test_accept_withdraw_projects.py

示例13: testCreateProfile

  def testCreateProfile(self):
    self.timeline_helper.studentSignup()

    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)

    self._updateDefaultProps(user)
    postdata = self.default_props

    response = self.post(self.student_url, postdata)
    self.assertResponseRedirect(response, self.validated_url)

    # hacky
    profile = profile_model.GCIProfile.all().get()
    profile.delete()

    postdata.update({
        'email': '[email protected]',
        })

    response = self.post(self.student_url, postdata)

    # yes! this is the protocol for form posts. We get an OK response
    # with the response containing the form's GET request page whenever
    # the form has an error and could not be posted. This is the architecture
    # chosen in order to save the form error state's while rendering the
    # error fields.
    self.assertResponseOK(response)

    error_dict = response.context['error']
    self.assertIn('email', error_dict)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:31,代码来源:test_profile.py

示例14: testOrgAppCreateOrEditByProgramAdmin

  def testOrgAppCreateOrEditByProgramAdmin(self):
    """Tests that program admin can create an organization application.
    """
    # Make sure we do not have an org app for this test.
    self.org_app.delete()

    user = profile_utils.seedNDBUser(host_for=[self.program])
    profile_utils.loginNDB(user)

    url = '/gsoc/org/application/edit/' + self.gsoc.key().name()
    response = self.get(url)
    self.assertResponseOK(response)
    self.assertOrgAppCreateOrEditTemplatesUsed(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())
    print response.content
    self.assertResponseRedirect(response, url + '?validated')

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

示例15: 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


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