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


Python profile_utils.seedNDBStudent函数代码示例

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


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

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

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

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

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

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

示例6: setUp

  def setUp(self):
    super(ProposalDuplicatesTest, self).setUp()
    self.init()

    self.timeline_helper.studentSignup()

    # set the organization as accepted and allocate some slots
    self.org.status = org_model.Status.ACCEPTED
    self.org.slot_allocation = 10
    self.org.put()

    # the first student has a two duplicates and one non-accepted proposal
    self.student1 = profile_utils.seedNDBStudent(self.program)
    for _ in range(_FIRST_STUDENT_NUMBER_OF_DUPLICATES):
      proposal_utils.seedProposal(
          self.student1.key, self.program.key(), org_key=self.org.key,
          accept_as_project=True)
    proposal_utils.seedProposal(
        self.student1.key, self.program.key(), org_key=self.org.key,
        accept_as_project=False)

    # the other student has two proposals; one of them is to be accepted.
    self.student2 = profile_utils.seedNDBStudent(self.program)
    proposal_utils.seedProposal(
        self.student2.key, self.program.key(), org_key=self.org.key,
        accept_as_project=True)
    proposal_utils.seedProposal(
        self.student2.key, self.program.key(), org_key=self.org.key,
        accept_as_project=False)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:29,代码来源:test_proposal_duplicates.py

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

示例8: testGradingRecordsOverviewGet

  def testGradingRecordsOverviewGet(self):
    grading_survey_group = self.createGradingSurveyGroup()
    url = '/gsoc/grading_records/overview/%s/%d' % (
        self.program.key().name(), grading_survey_group.key().id())
    response = self.get(url)
    self.assertResponseOK(response)
    self.assertGradingRecordsOverviewTemplatesUsed(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 = project_utils.seedProject(
        student, self.program.key(), org_key=self.org.key)

    other_student = profile_utils.seedNDBStudent(self.program)
    project_utils.seedProject(
        other_student, self.program.key(), org_key=self.org.key)

    grading_record.updateOrCreateRecordsFor(grading_survey_group, [project])

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

示例9: testCodeInStudentAccessDenied

  def testCodeInStudentAccessDenied(self):
    """Tests that Code-in student cannot access the page."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

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

示例10: testForStudentProfile

  def testForStudentProfile(self):
    """Tests that False is returned if a student profile exists."""
    # seed a student profile
    profile_utils.seedNDBStudent(self.program, user=self.user)

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

示例11: testStudentAccessDenied

  def testStudentAccessDenied(self):
    """Tests that students cannot access the page."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

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

示例12: setUp

  def setUp(self):
    self.program = program_utils.seedGSoCProgram()
    # An organization which has all its slots allocated.
    self.foo_organization = org_utils.seedSOCOrganization(
        self.program.key(), slot_allocation=2)

    self.foo_proposals = []
    for _ in range(2):
      student = profile_utils.seedNDBStudent(self.program)
      self.foo_proposals.append(
          proposal_utils.seedProposal(student.key, self.program.key(),
              org_key=self.foo_organization.key,
              status=proposal_model.STATUS_ACCEPTED))

    # Create an organization which has slots to be allocated. We create both
    # rejected and accepted proposals for this organization entity.
    self.bar_organization = org_utils.seedSOCOrganization(
        self.program.key(), slot_allocation=5)
    # Create some already accepted proposals for bar_organization.
    self.bar_accepted_proposals = []
    for _ in range(2):
      student = profile_utils.seedNDBStudent(self.program)
      self.bar_accepted_proposals.append(
          proposal_utils.seedProposal(student.key, self.program.key(),
              org_key=self.bar_organization.key,
              status=proposal_model.STATUS_ACCEPTED))
    # proposals which are yet to be accepted.
    self.bar_to_be_accepted_proposals = []
    for _ in range(3):
      student = profile_utils.seedNDBStudent(self.program)
      self.bar_to_be_accepted_proposals.append(
          proposal_utils.seedProposal(student.key, self.program.key(),
              org_key=self.bar_organization.key, accept_as_project=True,
              status=proposal_model.STATUS_PENDING))

    # proposals which were rejected.
    self.bar_rejected_proposals = []
    for _ in range(3):
      student = profile_utils.seedNDBStudent(self.program)
      self.bar_rejected_proposals.append(
          proposal_utils.seedProposal(student.key, self.program.key(),
              org_key=self.bar_organization.key, accept_as_project=False,
              status=proposal_model.STATUS_PENDING))

    # Create an organization for which the accepted proposals are more than
    # the available slots.
    self.happy_organization = org_utils.seedSOCOrganization(
        self.program.key(), slot_allocation=1)

    self.happy_accepted_proposals = []
    self.happy_accepted_proposals.append(
        proposal_utils.seedProposal(student.key, self.program.key(),
            org_key=self.happy_organization.key, score=2,
            status=proposal_model.STATUS_PENDING, accept_as_project=True))
    self.happy_accepted_proposals.append(
        proposal_utils.seedProposal(student.key, self.program.key(),
            org_key=self.happy_organization.key, score=5,
            status=proposal_model.STATUS_PENDING, accept_as_project=True))
开发者ID:rhyolight,项目名称:nupic.son,代码行数:58,代码来源:test_proposal.py

示例13: testStudentAccessForbidded

  def testStudentAccessForbidded(self):
    """Tests that a student cannot access the page."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

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

示例14: testStudentDeniedAccess

  def testStudentDeniedAccess(self):
    """Tests that students are denied access."""
    # seed a profile who is a student
    profile_utils.seedNDBStudent(self.program, user=self.user)

    access_checker = access.ProgramAdministratorAccessChecker()
    with self.assertRaises(exception.UserError) as context:
      access_checker.checkAccess(self.data, None)
    self.assertEqual(context.exception.message,
        access._MESSAGE_NOT_PROGRAM_ADMINISTRATOR)
开发者ID:rhyolight,项目名称:nupic.son,代码行数:10,代码来源:test_access.py

示例15: testPostButtonUnpublishByStudent

  def testPostButtonUnpublishByStudent(self):
    """Tests the unpublish button by a mentor."""
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBStudent(self.program, user=user)

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

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


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