Ejemplo n.º 1
0
  def testIsHostForProgram(self):
    """Tests that True is returned for a program host."""
    # seed a couple of programs
    program_one = program_utils.seedProgram()
    program_two = program_utils.seedProgram()

    # make the user a host for the first program but not for the other
    self.user.host_for = [ndb.Key.from_old_key(program_one.key())]
    self.user.put()

    # check that the user is a host only for the first program
    self.assertTrue(user_logic.isHostForProgram(self.user, program_one.key()))
    self.assertFalse(user_logic.isHostForProgram(self.user, program_two.key()))
Ejemplo n.º 2
0
    def testIsHostForProgram(self):
        """Tests that True is returned for a program host."""
        # seed a couple of programs
        program_one = program_utils.seedProgram()
        program_two = program_utils.seedProgram()

        # make the user a host for the first program but not for the other
        self.user.host_for = [ndb.Key.from_old_key(program_one.key())]
        self.user.put()

        # check that the user is a host only for the first program
        self.assertTrue(
            user_logic.isHostForProgram(self.user, program_one.key()))
        self.assertFalse(
            user_logic.isHostForProgram(self.user, program_two.key()))
Ejemplo n.º 3
0
    def setUp(self):
        """See unittest.TestCase.setUp for specification."""
        # seed a program
        self.program = program_utils.seedProgram()

        # seed a user
        self.user = profile_utils.seedNDBUser()
Ejemplo n.º 4
0
 def setUp(self):
   """See unittest.TestCase.setUp for specification."""
   self.program = program_utils.seedProgram()
   self.profile = profile_utils.seedNDBProfile(self.program.key())
   org = org_utils.seedOrganization(self.program.key())
   self.connection = connection_utils.seed_new_connection(
       self.profile.key, org.key)
Ejemplo n.º 5
0
 def setUp(self):
     """See unittest.TestCase.setUp for specification."""
     program = program_utils.seedProgram()
     self.survey = seeder_logic.seed(soc_survey_model.Survey)
     # TODO(daniel): NDB migration; no key translation after Survey migrates
     self.survey_key = ndb.Key.from_old_key(self.survey.key())
     self.profile = profile_utils.seedNDBProfile(program.key())
Ejemplo n.º 6
0
 def setUp(self):
     """See unittest.TestCase.setUp for specification."""
     program = program_utils.seedProgram()
     self.survey = seeder_logic.seed(soc_survey_model.Survey)
     # TODO(daniel): NDB migration; no key translation after Survey migrates
     self.survey_key = ndb.Key.from_old_key(self.survey.key())
     self.profile = profile_utils.seedNDBProfile(program.key())
Ejemplo n.º 7
0
  def setUp(self):
    """See unittest.TestCase.setUp for specification."""
    # seed two programs for the same sponsor
    sponsor = program_utils.seedSponsor()
    self.program_one = program_utils.seedProgram(sponsor_key=sponsor.key())
    program_two = program_utils.seedProgram(sponsor_key=sponsor.key())

    org_one = org_utils.seedOrganization(self.program_one.key())
    org_two = org_utils.seedOrganization(program_two.key())

    self.mentor_keys = set()
    # seed a few mentors for both programs
    for _ in range(_NUMBER_OF_MENTORS):
      self.mentor_keys.add(profile_utils.seedNDBProfile(
          self.program_one.key(), mentor_for=[org_one.key]).key)
      profile_utils.seedNDBProfile(program_two.key(), mentor_for=[org_two.key])
Ejemplo n.º 8
0
  def setUp(self):
    """See unittest.TestCase.setUp for specification."""
    # seed a program
    self.program = program_utils.seedProgram()

    # seed a user
    self.user = profile_utils.seedNDBUser()
Ejemplo n.º 9
0
    def setUp(self):

        self.user = profile_utils.seedNDBUser()

        self.program = program_utils.seedProgram()

        self.gsoc_program = program_utils.seedGSoCProgram()

        self.gci_program = program_utils.seedGCIProgram()

        self.site = seeder_logic.seed(Site, {'key_name': 'site'})

        self.organization = seeder_logic.seed(Organization)

        self.gsoc_organization = org_utils.seedSOCOrganization(
            self.gsoc_program.key())

        self.gci_organization = seeder_logic.seed(GCIOrganization)

        self.program_key_name = self.program.key().name()
        self.gsoc_program_key_name = self.gsoc_program.key().name()
        self.gci_program_key_name = self.gci_program.key().name()
        self.site_key_name = self.site.key().name()
        self.org_key_name = self.organization.key().name()
        self.gsoc_org_key_name = self.gsoc_organization.key.id()
        self.gci_org_key_name = self.gci_organization.key().name()
Ejemplo n.º 10
0
  def setUp(self):

    self.user = profile_utils.seedNDBUser()

    self.program = program_utils.seedProgram()

    self.gsoc_program = program_utils.seedGSoCProgram()

    self.gci_program = program_utils.seedGCIProgram()

    self.site = seeder_logic.seed(Site, {'key_name': 'site'})

    self.organization = seeder_logic.seed(Organization)

    self.gsoc_organization = org_utils.seedSOCOrganization(
        self.gsoc_program.key())

    self.gci_organization = seeder_logic.seed(GCIOrganization)

    self.program_key_name = self.program.key().name()
    self.gsoc_program_key_name = self.gsoc_program.key().name()
    self.gci_program_key_name = self.gci_program.key().name()
    self.site_key_name = self.site.key().name()
    self.org_key_name = self.organization.key().name()
    self.gsoc_org_key_name = self.gsoc_organization.key.id()
    self.gci_org_key_name = self.gci_organization.key().name()
Ejemplo n.º 11
0
 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)
Ejemplo n.º 12
0
  def setUp(self):
    """See unittest.TestCase.setUp for specification."""
    # seed a new program
    self.program = program_utils.seedProgram()

    # seed a couple of organizations
    self.organization_one = org_utils.seedOrganization(self.program.key())
    self.organization_two = org_utils.seedOrganization(self.program.key())
Ejemplo n.º 13
0
    def setUp(self):
        """See unittest.setUp for specification."""
        sponsor = program_utils.seedSponsor()
        self.program = program_utils.seedProgram(sponsor_key=sponsor.key())

        self.kwargs = {
            'sponsor': sponsor.key().name(),
            'program': self.program.program_id,
        }
Ejemplo n.º 14
0
  def setUp(self):
    """See unittest.setUp for specification."""
    sponsor = program_utils.seedSponsor()
    self.program = program_utils.seedProgram(sponsor_key=sponsor.key())

    self.kwargs = {
        'sponsor': sponsor.key().name(),
        'program': self.program.program_id,
        }
Ejemplo n.º 15
0
  def setUp(self):
    """See unittest.TestCase.setUp for specification."""
    self.user = profile_utils.seedNDBUser()
    self.program = program_utils.seedProgram()

    self.profile_key = ndb.Key(
      user_model.User._get_kind(), self.user.key.id(),
      ndb_profile_model.Profile._get_kind(),
      '%s/%s' % (self.program.key().name(), self.user.key.id()))
Ejemplo n.º 16
0
  def setUp(self):
    """See unittest.TestCase.setUp for specification."""
    program = program_utils.seedProgram()

    # seed an organization
    self.org = org_utils.seedOrganization(program.key())

    # seed a profile
    self.profile = profile_utils.seedNDBProfile(program.key())
Ejemplo n.º 17
0
    def setUp(self):
        """See unittest.TestCase.setUp for specification."""
        sponsor = program_utils.seedSponsor()
        self.program = program_utils.seedProgram(sponsor_key=sponsor.key())

        kwargs = {
            'sponsor': sponsor.key().name(),
            'program': self.program.program_id
        }
        self.data = request_data.RequestData(None, None, kwargs)
Ejemplo n.º 18
0
  def setUp(self):
    """See unittest.TestCase.setUp for specification."""
    sponsor = program_utils.seedSponsor()
    self.program = program_utils.seedProgram(sponsor_key=sponsor.key())

    kwargs = {
        'sponsor': sponsor.key().name(),
        'program': self.program.program_id,
        }
    self.data = request_data.RequestData(None, None, kwargs)
Ejemplo n.º 19
0
  def testProfile(self):
    # seed a program
    program = program_utils.seedProgram()

    # seed a profile
    profile = profile_utils.seedNDBProfile(program.key())

    self.assertEqual(
        '/gci/profile/show/%s/%s' % (
            profile.program.id(), profile.key.parent().id()),
        self.linker.profile(profile, gci_url_names.GCI_PROFILE_SHOW_ADMIN))
Ejemplo n.º 20
0
  def testQueryForAnonymousConnection(self):
    """Test that the function will correctly fetch AnonymousConnection objects
    given a valid token."""
    program = program_utils.seedProgram()
    org = org_utils.seedOrganization(program.key())

    connection_logic.createAnonymousConnection(org=org,
        org_role=connection_model.MENTOR_ROLE, email='*****@*****.**')
    token = connection_model.AnonymousConnection.all().get().token
    connection = connection_logic.queryAnonymousConnectionForToken(token)
    self.assertIsNotNone(connection)
Ejemplo n.º 21
0
  def setUp(self):
    """See unittest.TestCase.setUp for specification."""
    program = program_utils.seedProgram()
    self.org_app = program_utils.seedApplicationSurvey(program.key())
    self.org = org_utils.seedOrganization(program.key())

    self.kwargs = {
        'sponsor': org_model.getSponsorId(self.org.key),
        'program': org_model.getProgramId(self.org.key),
        'organization': org_model.getOrgId(self.org.key)
        }
Ejemplo n.º 22
0
  def testUserProfileForAnotherProgramAccessDenied(self):
    """Tests that access is denied if the profile is another program."""
    other_program = program_utils.seedProgram(sponsor_key=self.sponsor.key())
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)
    profile_utils.seedNDBProfile(other_program.key(), user=user)

    access_checker = access.HAS_PROFILE_ACCESS_CHECKER
    with self.assertRaises(exception.UserError) as context:
      access_checker.checkAccess(self.data, None)
    self.assertEqual(context.exception.status, httplib.FORBIDDEN)
Ejemplo n.º 23
0
    def setUp(self):
        """See unittest.TestCase.setUp for specification."""
        program = program_utils.seedProgram()
        self.org_app = program_utils.seedApplicationSurvey(program.key())
        self.org = org_utils.seedOrganization(program.key())

        self.kwargs = {
            'sponsor': org_model.getSponsorId(self.org.key),
            'program': org_model.getProgramId(self.org.key),
            'organization': org_model.getOrgId(self.org.key)
        }
Ejemplo n.º 24
0
  def testOrganization(self):
    """Tests organization function."""
    # seed a program
    program = program_utils.seedProgram()

    # seed an organization
    organization = org_utils.seedOrganization(program.key())

    url = self.linker.organization(
        organization.key, soc_urls.UrlNames.ORG_PROFILE_EDIT)
    self.assertEqual(
        '/gsoc/org/profile/edit/%s' % organization.key.id(), url)
Ejemplo n.º 25
0
  def setUp(self):
    """See unittest.TestCase.setUp for specification."""
    # seed a new program
    self.program = program_utils.seedProgram()

    # seed a couple of organizations
    self.organization_one = org_utils.seedOrganization(self.program.key())
    self.organization_two = org_utils.seedOrganization(self.program.key())

    # seed a new org admin for organization one
    self.org_admin = profile_utils.seedNDBProfile(
        self.program.key(), admin_for=[self.organization_one.key])
Ejemplo n.º 26
0
    def testUserProfileForAnotherProgramAccessDenied(self):
        """Tests that access is denied if the profile is another program."""
        other_program = program_utils.seedProgram(
            sponsor_key=self.sponsor.key())
        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)
        profile_utils.seedNDBProfile(other_program.key(), user=user)

        access_checker = access.HAS_PROFILE_ACCESS_CHECKER
        with self.assertRaises(exception.UserError) as context:
            access_checker.checkAccess(self.data, None)
        self.assertEqual(context.exception.status, httplib.FORBIDDEN)
Ejemplo n.º 27
0
  def testGetHostsForProgram(self):
    """Tests if a correct user entities are returned."""
    # seed a user to be initial host for the first program
    host = profile_utils.seedNDBUser()

    # seed two programs
    program_one = program_utils.seedProgram(host=host)
    program_two = program_utils.seedProgram()

    # seed hosts for the program one
    hosts = set([host.key])
    for _ in range(3):
      user_entity = profile_utils.seedNDBUser(host_for=[program_one])
      hosts.add(user_entity.key)

    # seed hosts for the program two
    for _ in range(2):
      user_entity = profile_utils.seedNDBUser(host_for=[program_two])

    # check that correct hosts for program one are returned
    actual_hosts = user_logic.getHostsForProgram(program_one.key())
    self.assertSetEqual(hosts, set(host.key for host in actual_hosts))
Ejemplo n.º 28
0
    def testGetHostsForProgram(self):
        """Tests if a correct user entities are returned."""
        # seed a user to be initial host for the first program
        host = profile_utils.seedNDBUser()

        # seed two programs
        program_one = program_utils.seedProgram(host=host)
        program_two = program_utils.seedProgram()

        # seed hosts for the program one
        hosts = set([host.key])
        for _ in range(3):
            user_entity = profile_utils.seedNDBUser(host_for=[program_one])
            hosts.add(user_entity.key)

        # seed hosts for the program two
        for _ in range(2):
            user_entity = profile_utils.seedNDBUser(host_for=[program_two])

        # check that correct hosts for program one are returned
        actual_hosts = user_logic.getHostsForProgram(program_one.key())
        self.assertSetEqual(hosts, set(host.key for host in actual_hosts))
Ejemplo n.º 29
0
  def testUserId(self):
    """Tests userId function."""
    # seed a program
    program = program_utils.seedProgram()

    # seed a profile
    profile = profile_utils.seedNDBProfile(program.key())

    self.assertEqual(
        '/gsoc/project/manage/admin/%s/%s/%s' % (
            program.key().name(), profile.key.parent().id(), 42),
        self.linker.userId(
            profile.key, 42, soc_urls.UrlNames.PROJECT_MANAGE_ADMIN))
Ejemplo n.º 30
0
    def testQueryForAnonymousConnection(self):
        """Test that the function will correctly fetch AnonymousConnection objects
    given a valid token."""
        program = program_utils.seedProgram()
        org = org_utils.seedOrganization(program.key())

        connection_logic.createAnonymousConnection(
            org=org,
            org_role=connection_model.MENTOR_ROLE,
            email='*****@*****.**')
        token = connection_model.AnonymousConnection.all().get().token
        connection = connection_logic.queryAnonymousConnectionForToken(token)
        self.assertIsNotNone(connection)
Ejemplo n.º 31
0
  def testCreateAnonymousConnection(self):
    """Test that an AnonymousConnection can be created successfully."""
    program = program_utils.seedProgram()
    org = org_utils.seedSOCOrganization(program.key())

    connection_logic.createAnonymousConnection(org=org,
        org_role=connection_model.MENTOR_ROLE, email='*****@*****.**')
    expected_expiration = datetime.today() + timedelta(7)

    connection = connection_model.AnonymousConnection.all().get()
    self.assertEquals(expected_expiration.date(),
        connection.expiration_date.date())
    self.assertEquals(connection_model.MENTOR_ROLE, connection.org_role)
    self.assertEquals('*****@*****.**', connection.email)
Ejemplo n.º 32
0
    def testUserCreated(self):
        """Tests that user entity is created."""
        program = program_utils.seedProgram()
        # 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, host_for=[ndb.Key.from_old_key(program.key())]))

        self.assertTrue(result)
        self.assertEqual(result.extra.key.id(), TEST_USERNAME)
        self.assertEqual(result.extra.account_id, TEST_ACCOUNT_ID)
        self.assertIn(ndb.Key.from_old_key(program.key()),
                      result.extra.host_for)
Ejemplo n.º 33
0
    def testForNonHostUser(self):
        """Tests that False is returned for a user who is not a host."""
        sponsor = program_utils.seedSponsor()
        program = program_utils.seedProgram(sponsor_key=sponsor.key())
        user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(user)

        kwargs = {
            'sponsor': sponsor.link_id,
            'program': program.program_id,
        }
        data = request_data.RequestData(None, None, kwargs)
        is_host = data.is_host
        self.assertFalse(is_host)
Ejemplo n.º 34
0
  def setUp(self):
    """See unittest.TestCase.setUp for specification."""
    self.sponsor = program_utils.seedSponsor()
    self.program = program_utils.seedProgram(sponsor_key=self.sponsor.key())

    # seed a user who will be tested for access
    self.user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(self.user)

    kwargs = {
        'sponsor': self.sponsor.key().name(),
        'program': self.program.program_id,
        }
    self.data = request_data.RequestData(None, None, kwargs)
Ejemplo n.º 35
0
  def testProfileExists(self):
    """Tests that profile is returned correctly if exists."""
    sponsor = program_utils.seedSponsor()
    program = program_utils.seedProgram(sponsor_key=sponsor.key())
    profile = profile_utils.seedNDBProfile(program.key())

    kwargs = {
        'sponsor': sponsor.link_id,
        'program': program.program_id,
        'user': profile.profile_id,
        }
    data = request_data.RequestData(None, None, kwargs)
    url_profile = data.url_ndb_profile
    self.assertEqual(profile.key, url_profile.key)
Ejemplo n.º 36
0
    def testProfileExists(self):
        """Tests that profile is returned correctly if exists."""
        sponsor = program_utils.seedSponsor()
        program = program_utils.seedProgram(sponsor_key=sponsor.key())
        profile = profile_utils.seedNDBProfile(program.key())

        kwargs = {
            'sponsor': sponsor.link_id,
            'program': program.program_id,
            'user': profile.profile_id,
        }
        data = request_data.RequestData(None, None, kwargs)
        url_profile = data.url_ndb_profile
        self.assertEqual(profile.key, url_profile.key)
Ejemplo n.º 37
0
  def testForNonHostUser(self):
    """Tests that False is returned for a user who is not a host."""
    sponsor = program_utils.seedSponsor()
    program = program_utils.seedProgram(sponsor_key=sponsor.key())
    user = profile_utils.seedNDBUser()
    profile_utils.loginNDB(user)

    kwargs = {
        'sponsor': sponsor.link_id,
        'program': program.program_id,
        }
    data = request_data.RequestData(None, None, kwargs)
    is_host = data.is_host
    self.assertFalse(is_host)
Ejemplo n.º 38
0
    def setUp(self):
        """See unittest.TestCase.setUp for specification."""
        sponsor = program_utils.seedSponsor()
        program = program_utils.seedProgram(sponsor_key=sponsor.key())
        self.survey = program_utils.seedApplicationSurvey(program.key())

        # seed some organizations with survey responses
        self.app_responses = set()
        for _ in range(TEST_ORGS_NUMBER):
            org = org_utils.seedOrganization(program.key())
            self.app_responses.add(
                org_utils.seedApplication(org.key, self.survey.key()).key)

        # seed some organizations without survey responses
        for _ in range(TEST_ORGS_NUMBER):
            org_utils.seedOrganization(program.key())

        other_program = program_utils.seedProgram(sponsor_key=sponsor.key())
        other_survey = program_utils.seedApplicationSurvey(other_program.key())

        # seed some organizations with survey responses for other survey
        for _ in range(TEST_ORGS_NUMBER):
            org = org_utils.seedOrganization(other_program.key())
            org_utils.seedApplication(org.key, other_survey.key())
Ejemplo n.º 39
0
  def setUp(self):
    """See unittest.TestCase.setUp for specification."""
    self.program = program_utils.seedProgram()

    self.orgs = []

    # seed some accepted organizations
    for _ in range(TEST_ORGS_NUMBER):
      self.orgs.append(org_utils.seedOrganization(
          self.program.key(), status=org_model.Status.ACCEPTED))

    # seed some rejected organizations
    for _ in range(TEST_ORGS_NUMBER):
      self.orgs.append(org_utils.seedOrganization(
          self.program.key(), status=org_model.Status.REJECTED))
Ejemplo n.º 40
0
  def setUp(self):
    """See unittest.TestCase.setUp for specification."""
    sponsor = program_utils.seedSponsor()
    program = program_utils.seedProgram(sponsor_key=sponsor.key())
    self.survey = program_utils.seedApplicationSurvey(program.key())

    # seed some organizations with survey responses
    self.app_responses = set()
    for _ in range(TEST_ORGS_NUMBER):
      org = org_utils.seedOrganization(program.key())
      self.app_responses.add(
          org_utils.seedApplication(org.key, self.survey.key()).key)

    # seed some organizations without survey responses
    for _ in range(TEST_ORGS_NUMBER):
      org_utils.seedOrganization(program.key())

    other_program = program_utils.seedProgram(sponsor_key=sponsor.key())
    other_survey = program_utils.seedApplicationSurvey(other_program.key())

    # seed some organizations with survey responses for other survey
    for _ in range(TEST_ORGS_NUMBER):
      org = org_utils.seedOrganization(other_program.key())
      org_utils.seedApplication(org.key, other_survey.key())
Ejemplo n.º 41
0
    def setUp(self):
        """See unittest.TestCase.setUp for specification."""
        self.sponsor = program_utils.seedSponsor()
        self.program = program_utils.seedProgram(
            sponsor_key=self.sponsor.key())

        # seed a user who will be tested for access
        self.user = profile_utils.seedNDBUser()
        profile_utils.loginNDB(self.user)

        kwargs = {
            'sponsor': self.sponsor.key().name(),
            'program': self.program.program_id,
        }
        self.data = request_data.RequestData(None, None, kwargs)
Ejemplo n.º 42
0
    def testCreateAnonymousConnection(self):
        """Test that an AnonymousConnection can be created successfully."""
        program = program_utils.seedProgram()
        org = org_utils.seedSOCOrganization(program.key())

        connection_logic.createAnonymousConnection(
            org=org,
            org_role=connection_model.MENTOR_ROLE,
            email='*****@*****.**')
        expected_expiration = datetime.today() + timedelta(7)

        connection = connection_model.AnonymousConnection.all().get()
        self.assertEquals(expected_expiration.date(),
                          connection.expiration_date.date())
        self.assertEquals(connection_model.MENTOR_ROLE, connection.org_role)
        self.assertEquals('*****@*****.**', connection.email)
Ejemplo n.º 43
0
  def testUserCreated(self):
    """Tests that user entity is created."""
    program = program_utils.seedProgram()
    # 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,
            host_for=[ndb.Key.from_old_key(program.key())]))

    self.assertTrue(result)
    self.assertEqual(result.extra.key.id(), TEST_USERNAME)
    self.assertEqual(result.extra.account_id, TEST_ACCOUNT_ID)
    self.assertIn(
        ndb.Key.from_old_key(program.key()), result.extra.host_for)
Ejemplo n.º 44
0
  def testUserOrg(self):
    """Tests userOrg function."""
    # seed a program
    program = program_utils.seedProgram()

    # seed a profile
    profile = profile_utils.seedNDBProfile(program.key())

    # seed an organization
    org = org_utils.seedOrganization(program.key())

    self.assertEqual(
        '/gci/student_tasks_for_org/%s/%s/%s' % (program.key().name(),
            profile.key.parent().id(), org.org_id),
        self.linker.userOrg(
            profile.key, org.key, gci_url_names.GCI_STUDENT_TASKS_FOR_ORG))
Ejemplo n.º 45
0
  def testOrgMemberWelcomeEmailSent(self):
    """Tests that welcome email is sent properly."""
    site = program_utils.seedSite()

    program = program_utils.seedProgram()
    program_messages = program_utils.seedProgramMessages(
        program_key=program.key())

    profile = profile_utils.seedNDBProfile(program.key())

    profile_logic.dispatchOrgMemberWelcomeEmail(
        profile, program, program_messages, site)

    self.assertEmailSent(
        to=profile.contact.email,
        subject=profile_logic._DEF_ORG_MEMBER_WELCOME_MAIL_SUBJECT)
Ejemplo n.º 46
0
    def testProjectExists(self):
        """Tests that project is returned correctly if exists."""
        sponsor = program_utils.seedSponsor()
        program = program_utils.seedProgram(sponsor_key=sponsor.key())

        profile = profile_utils.seedSOCStudent(program)
        project = project_utils.seedProject(profile, program.key())

        kwargs = {
            'sponsor': sponsor.link_id,
            'program': program.program_id,
            'user': profile.profile_id,
            'id': str(project.key().id())
        }
        data = request_data.RequestData(None, None, kwargs)
        url_project = data.url_project
        self.assertEqual(project.key(), url_project.key())
Ejemplo n.º 47
0
    def setUp(self):
        """See unittest.TestCase.setUp for specification."""
        self.program = program_utils.seedProgram()

        self.orgs = []

        # seed some accepted organizations
        for _ in range(TEST_ORGS_NUMBER):
            self.orgs.append(
                org_utils.seedOrganization(self.program.key(),
                                           status=org_model.Status.ACCEPTED))

        # seed some rejected organizations
        for _ in range(TEST_ORGS_NUMBER):
            self.orgs.append(
                org_utils.seedOrganization(self.program.key(),
                                           status=org_model.Status.REJECTED))
Ejemplo n.º 48
0
  def testProjectExists(self):
    """Tests that project is returned correctly if exists."""
    sponsor = program_utils.seedSponsor()
    program = program_utils.seedProgram(sponsor_key=sponsor.key())

    profile = profile_utils.seedSOCStudent(program)
    project = project_utils.seedProject(profile, program.key())

    kwargs = {
        'sponsor': sponsor.link_id,
        'program': program.program_id,
        'user': profile.profile_id,
        'id': str(project.key().id())
        }
    data = request_data.RequestData(None, None, kwargs)
    url_project = data.url_project
    self.assertEqual(project.key(), url_project.key())
Ejemplo n.º 49
0
  def testConnectionExists(self):
    """Tests that connection is returned correctly if exists."""
    sponsor = program_utils.seedSponsor()
    program = program_utils.seedProgram(sponsor_key=sponsor.key())
    org = org_utils.seedOrganization(program.key())

    profile = profile_utils.seedNDBProfile(program.key())
    connection = connection_utils.seed_new_connection(profile.key, org.key)

    kwargs = {
        'sponsor': sponsor.link_id,
        'program': program.program_id,
        'user': profile.profile_id,
        'id': str(connection.key.id())
        }
    data = request_data.RequestData(None, None, kwargs)
    url_connection = data.url_connection
    self.assertEqual(connection.key, url_connection.key)
Ejemplo n.º 50
0
    def testConnectionExists(self):
        """Tests that connection is returned correctly if exists."""
        sponsor = program_utils.seedSponsor()
        program = program_utils.seedProgram(sponsor_key=sponsor.key())
        org = org_utils.seedOrganization(program.key())

        profile = profile_utils.seedNDBProfile(program.key())
        connection = connection_utils.seed_new_connection(profile.key, org.key)

        kwargs = {
            'sponsor': sponsor.link_id,
            'program': program.program_id,
            'user': profile.profile_id,
            'id': str(connection.key.id())
        }
        data = request_data.RequestData(None, None, kwargs)
        url_connection = data.url_connection
        self.assertEqual(connection.key, url_connection.key)
Ejemplo n.º 51
0
    def setUp(self):
        """See unittest.TestCase.setUp for specification."""
        program = program_utils.seedProgram()
        # seed a few organizations
        self.first_org = org_utils.seedOrganization(program.key())
        self.second_org = org_utils.seedOrganization(program.key())
        self.third_org = org_utils.seedOrganization(program.key())

        # seed a few profiles
        first_profile = profile_utils.seedNDBProfile(program.key())
        second_profile = profile_utils.seedNDBProfile(program.key())

        self.first_connection = connection_utils.seed_new_connection(
            first_profile.key, self.first_org.key)
        self.second_connection = connection_utils.seed_new_connection(
            second_profile.key, self.first_org.key)
        self.third_connection = connection_utils.seed_new_connection(
            first_profile.key, self.second_org.key)
Ejemplo n.º 52
0
 def setUp(self):
     """See unittest.TestCase.setUp for specification."""
     self.program = program_utils.seedProgram()
Ejemplo n.º 53
0
 def setUp(self):
     self.program = program_utils.seedProgram()
     self.survey = seeder_logic.seed(soc_survey_model.Survey)
     self.profile = profile_utils.seedNDBProfile(self.program.key())
Ejemplo n.º 54
0
 def setUp(self):
     """See unittest.TestCase.setUp for specification."""
     program = program_utils.seedProgram()
     self.profile = profile_utils.seedSOCStudent(program)