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


Python profile_utils.seedNDBUser函数代码示例

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


在下文中一共展示了seedNDBUser函数的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: testForNonLoggedInAccount

  def testForNonLoggedInAccount(self):
    """Tests that None is returned for a not logged-in user."""
    # seed a user but make sure that nobody is logged in
    profile_utils.seedNDBUser()
    profile_utils.logout()

    result = user_logic.getByCurrentAccount()
    self.assertIsNone(result)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:8,代码来源:test_user.py

示例3: testUserExists

  def testUserExists(self):
    """Tests that user entity is not existed for a taken username."""
    # seed a user with a specific username
    profile_utils.seedNDBUser(user_id=TEST_USERNAME)

    # sign in a user with an account but with no user entity
    profile_utils.signInToGoogleAccount(TEST_EMAIL, TEST_ACCOUNT_ID)

    result = ndb.transaction(lambda: user_logic.createUser(TEST_USERNAME))
    self.assertFalse(result)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:10,代码来源:test_user.py

示例4: setUp

  def setUp(self):
    """Set up required for the cleaning logic tests.
    """
    self.init()
    # Ensure that current user is created
    self.user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(self.user)

    # Create another user
    self.another_user = profile_utils.seedNDBUser()

    # Create a dummy form object
    self.form = Form()
开发者ID:rhyolight,项目名称:nupic.son,代码行数:13,代码来源:test_cleaning.py

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

示例6: testSubmitProposalWhenInactive

  def testSubmitProposalWhenInactive(self):
    """Test the submission of student proposals during the student signup
    period is not active.
    """
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

    self.timeline_helper.orgSignup()
    url = '/gsoc/proposal/submit/' + self.org.key.id()
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.timeline_helper.offSeason()
    url = '/gsoc/proposal/submit/' + self.org.key.id()
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.timeline_helper.kickoff()
    url = '/gsoc/proposal/submit/' + self.org.key.id()
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.timeline_helper.orgsAnnounced()
    url = '/gsoc/proposal/submit/' + self.org.key.id()
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.timeline_helper.studentsAnnounced()
    url = '/gsoc/proposal/submit/' + self.org.key.id()
    response = self.get(url)
    self.assertResponseForbidden(response)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:32,代码来源:test_proposal.py

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

示例8: seedApplicationSurvey

def seedApplicationSurvey(program_key, **kwargs):
  """Seeds a new organization application survey for the specified program.

  Args:
    program_key: Program key to create a survey for.
    kwargs: Optional values for other properties of the seeded entity.

  Returns:
    Newly seeded survey entity.
  """
  user = profile_utils.seedNDBUser()
  program = db.get(program_key)

  properties = {
      'scope': program_key,
      'program': program_key,
      'modified_by': user.key.to_old_key(),
      'created_by': user.key.to_old_key(),
      'author': user.key.to_old_key(),
      'schema': ('[["item"],{"item":{"field_type":"input_text",'
                 '"required":false, "label":"test"}}]'),
      'survey_content': None,
      'key_name': '%s/%s/orgapp' % (program.prefix, program_key.name())
      }
  properties.update(kwargs)
  return seeder_logic.seed(OrgAppSurvey, properties)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:26,代码来源:program_utils.py

示例9: testWithdrawProjects

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

    self.timeline_helper.studentsAnnounced()

    url = '/gsoc/withdraw_projects/' + self.program.key().name()
    response = self.get(url)
    self.assertResponseOK(response)
    self.assertWithdrawProjects(response)

    # list response without any projects
    response = self.getListResponse(url, 0)
    self.assertIsJsonResponse(response)
    data = response.context['data']['']
    self.assertEqual(0, len(data))

    # list response with projects
    student = profile_utils.seedNDBStudent(self.program)
    project_utils.seedProject(student, 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_withdraw_projects.py

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

示例11: testProgramHostAccessGranted

  def testProgramHostAccessGranted(self):
    """Asserts program administrators can access the page."""
    user = profile_utils.seedNDBUser(host_for=[self.program])
    profile_utils.loginNDB(user)

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

示例12: testPostSubmitWork

  def testPostSubmitWork(self):
    """Tests for submitting work."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedNDBStudent(self.program, user=user)

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

    no_work = self.task.workSubmissions()
    self.assertEqual(len(no_work), 0)

    work_url = 'http://www.example.com/'
    work_data = {
        'url_to_work': work_url
    }

    url = '%s?submit_work' % _taskPageURL(self.task)
    response = self.post(url, work_data)

    self.assertResponseRedirect(response)

    one_work = self.task.workSubmissions()
    self.assertEqual(len(one_work), 1)

    work = one_work[0]
    self.assertEqual(work_url, work.url_to_work)

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

示例13: testPostButtonUnclaim

  def testPostButtonUnclaim(self):
    """Tests the unclaim task button."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedNDBStudent(self.program, user=user)

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

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

    # check if the task is properly opened
    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,代码行数:26,代码来源:test_task.py

示例14: testPostButtonClaim

  def testPostButtonClaim(self):
    """Tests the claim task button."""
    form = forms_to_submit_utils.FormsToSubmitHelper().createBlobStoreForm()
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    student = profile_utils.seedNDBStudent(
        self.program, user=user,
        student_data_properties={'enrollment_form': form, 'consent_form':form})

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

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

    # 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,代码行数:26,代码来源:test_task.py

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


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