Beispiel #1
0
    def testSurveyResponseTab(self):
        """Tests that survey response tab has the right URL."""
        # organization application is now
        self.org_app.survey_start = timeline_utils.past()
        self.org_app.survey_end = timeline_utils.future()
        self.org_app.put()

        data = request_data.RequestData(None, None, self.kwargs)
        tabs = soc_tabs.orgTabs(data)

        survey_response_tab = [
            tab for tab in tabs.tabs
            if tab.tab_id == soc_tabs.ORG_APP_RESPONSE_TAB_ID
        ][0]
        self.assertEqual('/gsoc/org/application/submit/%s' % self.org.key.id(),
                         survey_response_tab.url)

        # organization application is complete
        self.org_app.survey_start = timeline_utils.past(delta=100)
        self.org_app.survey_end = timeline_utils.past(delta=50)
        self.org_app.put()

        data = request_data.RequestData(None, None, self.kwargs)
        tabs = soc_tabs.orgTabs(data)

        survey_response_tab = [
            tab for tab in tabs.tabs
            if tab.tab_id == soc_tabs.ORG_APP_RESPONSE_TAB_ID
        ][0]
        self.assertEqual(
            '/gsoc/org/survey_response/show/%s' % self.org.key.id(),
            survey_response_tab.url)
    def testBeforeOrgSignupStart(self):
        """Tests for beforeOrgSignupStart function."""
        # organization application has yet to start
        self.timeline_helper.org_app.survey_start = timeline_utils.future(
            delta=1)
        self.timeline_helper.org_app.survey_end = timeline_utils.future(
            delta=2)
        self.assertTrue(self.timeline_helper.beforeOrgSignupStart())

        # organization application has started
        self.timeline_helper.org_app.survey_start = timeline_utils.past(
            delta=1)
        self.timeline_helper.org_app.survey_end = timeline_utils.future(
            delta=2)
        self.assertFalse(self.timeline_helper.beforeOrgSignupStart())

        # organization application has ended
        self.timeline_helper.org_app.survey_start = timeline_utils.past(
            delta=2)
        self.timeline_helper.org_app.survey_end = timeline_utils.past(delta=1)
        self.assertFalse(self.timeline_helper.beforeOrgSignupStart())

        # no organization application is defined
        self.timeline_helper.org_app = None
        self.assertTrue(self.timeline_helper.beforeOrgSignupStart())
Beispiel #3
0
    def testForNotActiveProgram(self):
        """Tests that access if denied if the program is not active."""
        data = request_data.RequestData(None, None, None)
        data._program = self.program
        data._timeline = request_data.TimelineHelper(self.program.timeline,
                                                     None)

        access_checker = access.ProgramActiveAccessChecker()

        # the program is not visible
        data._program.status = program_model.STATUS_INVISIBLE
        data._program.timeline.program_start = timeline_utils.past()
        data._program.timeline.program_end = timeline_utils.future()
        with self.assertRaises(exception.UserError) as context:
            access_checker.checkAccess(data, None)
        self.assertEqual(context.exception.message,
                         access._MESSAGE_PROGRAM_NOT_ACTIVE)

        # the program is has already ended
        data._program.status = program_model.STATUS_VISIBLE
        data._program.timeline.program_start = timeline_utils.past(delta=100)
        data._program.timeline.program_end = timeline_utils.past(delta=50)
        with self.assertRaises(exception.UserError) as context:
            access_checker.checkAccess(data, None)
        self.assertEqual(context.exception.message,
                         access._MESSAGE_PROGRAM_NOT_ACTIVE)
Beispiel #4
0
  def testForNotActiveProgram(self):
    """Tests that access if denied if the program is not active."""
    data = request_data.RequestData(None, None, None)
    data._program = self.program
    data._timeline = request_data.TimelineHelper(self.program.timeline, None)

    access_checker = access.ProgramActiveAccessChecker()

    # the program is not visible
    data._program.status = program_model.STATUS_INVISIBLE
    data._program.timeline.program_start = timeline_utils.past()
    data._program.timeline.program_end = timeline_utils.future()
    with self.assertRaises(exception.UserError) as context:
      access_checker.checkAccess(data, None)
    self.assertEqual(context.exception.message,
        access._MESSAGE_PROGRAM_NOT_ACTIVE)

    # the program is has already ended
    data._program.status = program_model.STATUS_VISIBLE
    data._program.timeline.program_start = timeline_utils.past(delta=100)
    data._program.timeline.program_end = timeline_utils.past(delta=50)
    with self.assertRaises(exception.UserError) as context:
      access_checker.checkAccess(data, None)
    self.assertEqual(context.exception.message,
        access._MESSAGE_PROGRAM_NOT_ACTIVE)
Beispiel #5
0
    def testSurveyActiveWithExtension(self):
        """Tests for survey that has personal extension for the profile."""
        # survey has ended
        self.survey.survey_start = timeline_utils.past(delta=200)
        self.survey.survey_end = timeline_utils.past(delta=100)

        # seed an extension
        self.extension = survey_model.PersonalExtension(
            parent=self.profile.key, survey=self.survey_key)
        self.extension.end_date = timeline_utils.future()
        self.extension.put()

        result = survey_logic.isSurveyActive(self.survey, self.profile.key)
        self.assertTrue(result)

        # survey has not started
        self.survey.survey_start = timeline_utils.future(delta=100)
        self.survey.survey_end = timeline_utils.future(delta=200)

        # set the extension so that the survey can be accessed now
        self.extension.end_date = None
        self.extension.start_date = timeline_utils.past()

        result = survey_logic.isSurveyActive(self.survey, self.profile.key)
        self.assertTrue(result)
Beispiel #6
0
  def testSurveyResponseTab(self):
    """Tests that survey response tab has the right URL."""
    # organization application is now
    self.org_app.survey_start = timeline_utils.past()
    self.org_app.survey_end = timeline_utils.future()
    self.org_app.put()

    data = request_data.RequestData(None, None, self.kwargs)
    tabs = soc_tabs.orgTabs(data)

    survey_response_tab = [
        tab for tab in tabs.tabs
        if tab.tab_id == soc_tabs.ORG_APP_RESPONSE_TAB_ID][0]
    self.assertEqual(
        '/gsoc/org/application/submit/%s' % self.org.key.id(),
        survey_response_tab.url)

    # organization application is complete
    self.org_app.survey_start = timeline_utils.past(delta=100)
    self.org_app.survey_end = timeline_utils.past(delta=50)
    self.org_app.put()

    data = request_data.RequestData(None, None, self.kwargs)
    tabs = soc_tabs.orgTabs(data)

    survey_response_tab = [
        tab for tab in tabs.tabs
        if tab.tab_id == soc_tabs.ORG_APP_RESPONSE_TAB_ID][0]
    self.assertEqual(
        '/gsoc/org/survey_response/show/%s' % self.org.key.id(),
        survey_response_tab.url)
    def createSurveys(self):
        """Creates the surveys and records required for the tests.
    """
        user = profile_utils.seedNDBUser(host_for=[self.program])
        survey_values = {
            "author": user.key.to_old_key(),
            "title": "Title",
            "modified_by": user.key.to_old_key(),
            "link_id": "link_id",
            "scope": self.program.key(),
            "survey_start": timeline_utils.past(),
            "survey_end": timeline_utils.past(),
        }

        self.project_survey = ps_model.ProjectSurvey(key_name="key_name", **survey_values)
        self.project_survey.put()

        self.grading_survey = gps_model.GradingProjectSurvey(key_name="key_name", **survey_values)
        self.grading_survey.put()

        record_values = {
            "user": self.student.key.parent().to_old_key(),
            "org": self.org.key.to_old_key(),
            "project": self.project,
            "survey": self.project_survey,
        }
        self.project_survey_record = psr_model.GSoCProjectSurveyRecord(**record_values)
        self.project_survey_record.put()

        self.grading_survey = gps_model.GradingProjectSurvey(**survey_values)
        self.grading_survey.put()

        record_values = {
            "user": self.student.key.parent().to_old_key(),
            "org": self.org.key.to_old_key(),
            "project": self.project,
            "survey": self.grading_survey,
            "grade": True,
        }
        self.grading_survey_record = gpsr_model.GSoCGradingProjectSurveyRecord(**record_values)
        self.grading_survey_record.put()

        group_values = {
            "name": "Survey Group Name",
            "grading_survey": self.grading_survey,
            "student_survey": self.project_survey,
            "program": self.program,
        }
        self.survey_group = gsg_model.GSoCGradingSurveyGroup(**group_values)
        self.survey_group.put()

        record_values = {
            "grading_survey_group": self.survey_group,
            "mentor_record": self.grading_survey_record,
            "student_record": self.project_survey_record,
            "grade_decision": "pass",
        }
        self.grading_record = gr_model.GSoCGradingRecord(parent=self.project, **record_values)
        self.grading_record.put()
Beispiel #8
0
  def testAfterOrgSignupEndedAccessGranted(self):
    """Tests that access is granted after organization sign-up ends."""
    self.app_survey.survey_start = timeline_utils.past(delta=150)
    self.app_survey.survey_end = timeline_utils.past(delta=100)
    self.app_survey.put()

    access_checker = access.OrgSignupStartedAccessChecker()
    access_checker.checkAccess(self.data, None)
Beispiel #9
0
    def testAfterOrgSignupEndedAccessGranted(self):
        """Tests that access is granted after organization sign-up ends."""
        self.app_survey.survey_start = timeline_utils.past(delta=150)
        self.app_survey.survey_end = timeline_utils.past(delta=100)
        self.app_survey.put()

        access_checker = access.OrgSignupStartedAccessChecker()
        access_checker.checkAccess(self.data, None)
Beispiel #10
0
  def testAfterStudentSignUp(self):
    """Tests that correct message is returned after student sign-up."""
    self.program.timeline.student_signup_start = timeline_utils.past(delta=150)
    self.program.timeline.student_signup_end = timeline_utils.past(delta=100)
    self.program.timeline.put()

    message = top_message.orgMemberRegistrationTopMessage(self.data)
    self.assertIsNone(message)
Beispiel #11
0
  def testAfterStudentSignupAccessDenied(self):
    """Tests that access is denied after student sign-up period."""
    self.program.timeline.student_signup_start = timeline_utils.past(delta=20)
    self.program.timeline.student_signup_end = timeline_utils.past(delta=10)
    self.program.timeline.put()

    access_checker = access.StudentSignupActiveAccessChecker()
    with self.assertRaises(exception.UserError) as context:
      access_checker.checkAccess(self.data, None)
    self.assertEqual(context.exception.status, httplib.FORBIDDEN)
Beispiel #12
0
  def testAfterOrgSignupAccessDenied(self):
    """Tests that access is denied after organization sign-up ends."""
    self.app_survey.survey_start = timeline_utils.past(delta=150)
    self.app_survey.survey_end = timeline_utils.past(delta=100)
    self.app_survey.put()

    access_checker = access.OrgSignupActiveAccessChecker()
    with self.assertRaises(exception.UserError) as context:
      access_checker.checkAccess(self.data, None)
    self.assertEqual(context.exception.status, httplib.FORBIDDEN)
Beispiel #13
0
    def testAfterOrgSignupAccessDenied(self):
        """Tests that access is denied after organization sign-up ends."""
        self.app_survey.survey_start = timeline_utils.past(delta=150)
        self.app_survey.survey_end = timeline_utils.past(delta=100)
        self.app_survey.put()

        access_checker = access.OrgSignupActiveAccessChecker()
        with self.assertRaises(exception.UserError) as context:
            access_checker.checkAccess(self.data, None)
        self.assertEqual(context.exception.status, httplib.FORBIDDEN)
Beispiel #14
0
    def testAfterStudentSignUp(self):
        """Tests that correct message is returned after student sign-up."""
        self.program.timeline.student_signup_start = timeline_utils.past(
            delta=150)
        self.program.timeline.student_signup_end = timeline_utils.past(
            delta=100)
        self.program.timeline.put()

        message = top_message.orgMemberRegistrationTopMessage(self.data)
        self.assertIsNone(message)
Beispiel #15
0
  def testAfterAcceptedStudentsAnnounced(self):
    """Tests that proposal cannot be resubmitted after announcing students."""
    # move the student app period to the future
    self.timeline.student_signup_end = timeline_utils.past()
    self.timeline.accepted_students_announced_deadline = timeline_utils.past()
    self.timeline.put()

    # it should not be possible to resubmit this proposal
    can_resubmit = proposal_logic.canProposalBeResubmitted(
        self.proposal, self.student, self.program, self.timeline)
    self.assertFalse(can_resubmit)
Beispiel #16
0
    def testAfterAcceptedStudentsAnnounced(self):
        """Tests that proposal cannot be resubmitted after announcing students."""
        # move the student app period to the future
        self.timeline.student_signup_end = timeline_utils.past()
        self.timeline.accepted_students_announced_deadline = timeline_utils.past(
        )
        self.timeline.put()

        # it should not be possible to resubmit this proposal
        can_resubmit = proposal_logic.canProposalBeResubmitted(
            self.proposal, self.student, self.program, self.timeline)
        self.assertFalse(can_resubmit)
Beispiel #17
0
  def testMessagesOrdered(self):
    """Tests that the returned messages are ordered by creation date."""
    # seed a couple of messages for the connection
    message1 = connection_utils.seed_new_connection_message(
        self.connection.key, created=datetime.now())
    message2 = connection_utils.seed_new_connection_message(
        self.connection.key, created=timeline_utils.past(delta=100))
    message3 = connection_utils.seed_new_connection_message(
        self.connection.key, created=timeline_utils.past(delta=50))

    messages = connection_logic.getConnectionMessages(self.connection.key)
    self.assertListEqual([message2, message3, message1], messages)
Beispiel #18
0
    def testAfterStudentSignupAccessDenied(self):
        """Tests that access is denied after student sign-up period."""
        self.program.timeline.student_signup_start = timeline_utils.past(
            delta=20)
        self.program.timeline.student_signup_end = timeline_utils.past(
            delta=10)
        self.program.timeline.put()

        access_checker = access.StudentSignupActiveAccessChecker()
        with self.assertRaises(exception.UserError) as context:
            access_checker.checkAccess(self.data, None)
        self.assertEqual(context.exception.status, httplib.FORBIDDEN)
Beispiel #19
0
    def testMessagesOrdered(self):
        """Tests that the returned messages are ordered by creation date."""
        # seed a couple of messages for the connection
        message1 = connection_utils.seed_new_connection_message(
            self.connection.key, created=datetime.now())
        message2 = connection_utils.seed_new_connection_message(
            self.connection.key, created=timeline_utils.past(delta=100))
        message3 = connection_utils.seed_new_connection_message(
            self.connection.key, created=timeline_utils.past(delta=50))

        messages = connection_logic.getConnectionMessages(self.connection.key)
        self.assertListEqual([message2, message3, message1], messages)
Beispiel #20
0
    def testForBoundPeriod(self):
        """Tests state for periods with both start and end dates."""
        # set the start and end dates to the past so it is after the period
        period = survey_logic.Period(start=timeline_utils.past(), end=timeline_utils.past())
        self.assertEqual(period.state, survey_logic.POST_PERIOD_STATE)

        # set the start date to the past and the end date to the future
        # so it is in the period
        period = survey_logic.Period(start=timeline_utils.past(), end=timeline_utils.future())
        self.assertEqual(period.state, survey_logic.IN_PERIOD_STATE)

        # set the start and end dates to the past so it is before the period
        period = survey_logic.Period(start=timeline_utils.future(), end=timeline_utils.future())
        self.assertEqual(period.state, survey_logic.PRE_PERIOD_STATE)
Beispiel #21
0
  def testPostActivePeriodAccessDenied(self):
    """Tests that access is forbidden after org application is closed."""
    # make org application active in the past
    self.updateOrgAppSurvey(survey_start=timeline_utils.past(delta=150),
        survey_end=timeline_utils.past(delta=100))

    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.take_url)
    self.assertResponseForbidden(response)
Beispiel #22
0
    def testSurveyHasStarted(self):
        """Tests for survey that has already started."""
        # survey is in active state
        self.survey.survey_start = timeline_utils.past(delta=100)
        self.survey.survey_end = timeline_utils.future(delta=100)

        result = survey_logic.hasSurveyStarted(self.survey, self.profile.key)
        self.assertTrue(result)

        # survey has already ended
        self.survey.survey_start = timeline_utils.past(delta=200)
        self.survey.survey_end = timeline_utils.past(delta=100)

        result = survey_logic.hasSurveyStarted(self.survey, self.profile.key)
        self.assertTrue(result)
Beispiel #23
0
    def testSurveyHasStarted(self):
        """Tests for survey that has already started."""
        # survey is in active state
        self.survey.survey_start = timeline_utils.past(delta=100)
        self.survey.survey_end = timeline_utils.future(delta=100)

        result = survey_logic.hasSurveyStarted(self.survey, self.profile.key)
        self.assertTrue(result)

        # survey has already ended
        self.survey.survey_start = timeline_utils.past(delta=200)
        self.survey.survey_end = timeline_utils.past(delta=100)

        result = survey_logic.hasSurveyStarted(self.survey, self.profile.key)
        self.assertTrue(result)
Beispiel #24
0
    def testSurveyIsNotActive(self):
        """Tests for survey that is not active."""
        # check for survey that has ended
        self.survey.survey_start = timeline_utils.past(delta=200)
        self.survey.survey_end = timeline_utils.past(delta=100)

        result = survey_logic.isSurveyActive(self.survey, self.profile.key)
        self.assertFalse(result)

        # check for survey that has yet to start
        self.survey.survey_start = timeline_utils.future(delta=100)
        self.survey.survey_end = timeline_utils.future(delta=200)

        result = survey_logic.isSurveyActive(self.survey, self.profile.key)
        self.assertFalse(result)
Beispiel #25
0
    def testSurveyIsNotActive(self):
        """Tests for survey that is not active."""
        # check for survey that has ended
        self.survey.survey_start = timeline_utils.past(delta=200)
        self.survey.survey_end = timeline_utils.past(delta=100)

        result = survey_logic.isSurveyActive(self.survey, self.profile.key)
        self.assertFalse(result)

        # check for survey that has yet to start
        self.survey.survey_start = timeline_utils.future(delta=100)
        self.survey.survey_end = timeline_utils.future(delta=200)

        result = survey_logic.isSurveyActive(self.survey, self.profile.key)
        self.assertFalse(result)
Beispiel #26
0
    def testExtensionIsUpdated(self):
        """Tests that extension can be updated."""
        extension = survey_model.PersonalExtension(parent=self.profile.key,
                                                   survey=self.survey_key)
        extension.put()

        # set new dates
        start_date = timeline_utils.past()
        end_date = timeline_utils.future()
        result = survey_logic.createOrUpdatePersonalExtension(
            self.profile.key,
            self.survey.key(),
            start_date=start_date,
            end_date=end_date)

        # check that the dates are updated
        self.assertEqual(result.start_date, start_date)
        self.assertEqual(result.end_date, end_date)

        # try cleaning the dates
        result = survey_logic.createOrUpdatePersonalExtension(
            self.profile.key,
            self.survey.key(),
            start_date=None,
            end_date=None)

        # check that the dates are cleared
        self.assertIsNone(result.start_date)
        self.assertIsNone(result.end_date)
Beispiel #27
0
    def setUp(self):
        sponsor = program_utils.seedSponsor()

        # seed a timeline and set student app period for now
        self.timeline = program_utils.seedTimeline(
            models=types.SOC_MODELS,
            timeline_id=TEST_PROGRAM_ID,
            sponsor_key=sponsor.key(),
            student_signup_start=timeline_utils.past(),
            student_signup_end=timeline_utils.future(delta=50),
            accepted_students_announced_deadline=timeline_utils.future(
                delta=75))

        self.program = program_utils.seedGSoCProgram(
            program_id=TEST_PROGRAM_ID,
            sponsor_key=sponsor.key(),
            timeline_key=self.timeline.key(),
            app_tasks_limit=3)

        # seed a new student info
        self.student = profile_utils.seedNDBStudent(self.program)

        # seed a new proposal
        self.proposal = proposal_utils.seedProposal(
            self.student.key,
            self.program.key(),
            status=proposal_model.STATUS_WITHDRAWN)
Beispiel #28
0
def seedTimeline(models=types.MELANGE_MODELS,
    timeline_id=None, sponsor_key=None, **kwargs):
  """Seeds a new timeline.

  Args:
    models: Instance of types.Models that represent appropriate models.
    timeline_id: Identifier of the new timeline.
    sponsor_key: Sponsor key to be used as scope for the timeline.

  Returns:
    Newly seeded timeline entity.
  """
  timeline_id = timeline_id or string_provider.UniqueIDProvider().getValue()

  sponsor_key = sponsor_key or seedSponsor()

  properties = {
      'key_name': '%s/%s' % (sponsor_key.name(), timeline_id),
      'link_id': timeline_id,
      'program_start': timeline_utils.past(),
      'program_end': timeline_utils.future(),
      'scope': sponsor_key,
      }
  properties.update(kwargs)
  timeline = models.timeline_model(**properties)
  timeline.put()

  return timeline
Beispiel #29
0
    def testSurveyIsActive(self):
        """Tests for survey that is active."""
        self.survey.survey_start = timeline_utils.past(delta=100)
        self.survey.survey_end = timeline_utils.future(delta=100)

        result = survey_logic.isSurveyActive(self.survey, self.profile.key)
        self.assertTrue(result)
Beispiel #30
0
    def testSurveyIsActive(self):
        """Tests for survey that is active."""
        self.survey.survey_start = timeline_utils.past(delta=100)
        self.survey.survey_end = timeline_utils.future(delta=100)

        result = survey_logic.isSurveyActive(self.survey, self.profile.key)
        self.assertTrue(result)
Beispiel #31
0
    def setUp(self):
        self.init()
        self.url = '/gci/org/' + self.org.key().name()

        # set the date when tasks are published to past
        self.program.timeline.tasks_publicly_visible = timeline_utils.past()
        self.program.timeline.put()
Beispiel #32
0
def seedTimeline(models=types.MELANGE_MODELS,
                 timeline_id=None,
                 sponsor_key=None,
                 **kwargs):
    """Seeds a new timeline.

  Args:
    models: Instance of types.Models that represent appropriate models.
    timeline_id: Identifier of the new timeline.
    sponsor_key: Sponsor key to be used as scope for the timeline.

  Returns:
    Newly seeded timeline entity.
  """
    timeline_id = timeline_id or string_provider.UniqueIDProvider().getValue()

    sponsor_key = sponsor_key or seedSponsor()

    properties = {
        'key_name': '%s/%s' % (sponsor_key.name(), timeline_id),
        'link_id': timeline_id,
        'program_start': timeline_utils.past(),
        'program_end': timeline_utils.future(),
        'scope': sponsor_key,
    }
    properties.update(kwargs)
    timeline = models.timeline_model(**properties)
    timeline.put()

    return timeline
Beispiel #33
0
  def setUp(self):
    self.init()
    self.url = '/gci/org/' + self.org.key().name()

    # set the date when tasks are published to past
    self.program.timeline.tasks_publicly_visible = timeline_utils.past()
    self.program.timeline.put()
Beispiel #34
0
    def testForBoundPeriod(self):
        """Tests state for periods with both start and end dates."""
        # set the start and end dates to the past so it is after the period
        period = survey_logic.Period(start=timeline_utils.past(),
                                     end=timeline_utils.past())
        self.assertEqual(period.state, survey_logic.POST_PERIOD_STATE)

        # set the start date to the past and the end date to the future
        # so it is in the period
        period = survey_logic.Period(start=timeline_utils.past(),
                                     end=timeline_utils.future())
        self.assertEqual(period.state, survey_logic.IN_PERIOD_STATE)

        # set the start and end dates to the past so it is before the period
        period = survey_logic.Period(start=timeline_utils.future(),
                                     end=timeline_utils.future())
        self.assertEqual(period.state, survey_logic.PRE_PERIOD_STATE)
Beispiel #35
0
    def setUp(self):
        """See unittest.TestCase.setUp for specification."""
        self.init()

        # student registration is now
        self.program.timeline.student_signup_start = timeline_utils.past()
        self.program.timeline.student_signup_end = timeline_utils.future()
        self.program.timeline.put()
Beispiel #36
0
    def testAfterOrgsAnnouncedAccessGranted(self):
        """Tests that access is granted after orgs are announced."""
        self.program.timeline.accepted_organization_announced_deadline = (
            timeline_utils.past())
        self.program.timeline.put()

        access_checker = access.OrgsAnnouncedAccessChecker()
        access_checker.checkAccess(self.data, None)
Beispiel #37
0
  def testDuringOrgSignupAccessGranted(self):
    """Tests that access is granted during organization sign-up period."""
    self.app_survey.survey_start = timeline_utils.past()
    self.app_survey.survey_end = timeline_utils.future()
    self.app_survey.put()

    access_checker = access.OrgSignupActiveAccessChecker()
    access_checker.checkAccess(self.data, None)
Beispiel #38
0
 def testForNoExtension(self):
     """Tests active period if there is no extension."""
     # test for survey with both start and end dates
     self.survey.survey_start = timeline_utils.past()
     self.survey.survey_end = timeline_utils.future()
     period = survey_logic.getSurveyActivePeriod(self.survey)
     self.assertEquals(period.start, self.survey.survey_start)
     self.assertEquals(period.end, self.survey.survey_end)
Beispiel #39
0
  def testDuringStudentSignupAccessGranted(self):
    """Tests that access is granted during student sign-up period."""
    self.program.timeline.student_signup_start = timeline_utils.past(delta=10)
    self.program.timeline.student_signup_end = timeline_utils.future(delta=10)
    self.program.timeline.put()

    access_checker = access.StudentSignupActiveAccessChecker()
    access_checker.checkAccess(self.data, None)
Beispiel #40
0
  def testAfterOrgsAnnouncedAccessGranted(self):
    """Tests that access is granted after orgs are announced."""
    self.program.timeline.accepted_organization_announced_deadline = (
        timeline_utils.past())
    self.program.timeline.put()

    access_checker = access.OrgsAnnouncedAccessChecker()
    access_checker.checkAccess(self.data, None)
Beispiel #41
0
    def testDuringOrgSignupAccessGranted(self):
        """Tests that access is granted during organization sign-up period."""
        self.app_survey.survey_start = timeline_utils.past()
        self.app_survey.survey_end = timeline_utils.future()
        self.app_survey.put()

        access_checker = access.OrgSignupActiveAccessChecker()
        access_checker.checkAccess(self.data, None)
Beispiel #42
0
 def testForNoExtension(self):
     """Tests active period if there is no extension."""
     # test for survey with both start and end dates
     self.survey.survey_start = timeline_utils.past()
     self.survey.survey_end = timeline_utils.future()
     period = survey_logic.getSurveyActivePeriod(self.survey)
     self.assertEquals(period.start, self.survey.survey_start)
     self.assertEquals(period.end, self.survey.survey_end)
Beispiel #43
0
  def setUp(self):
    """See unittest.TestCase.setUp for specification."""
    self.init()

    # student registration is now
    self.program.timeline.student_signup_start = timeline_utils.past()
    self.program.timeline.student_signup_end = timeline_utils.future()
    self.program.timeline.put()
Beispiel #44
0
    def testForLeftUnboundPeriod(self):
        """Tests state for periods with no start date."""
        # set the end of period to the past so the period is already over
        period = survey_logic.Period(end=timeline_utils.past())
        self.assertEqual(period.state, survey_logic.POST_PERIOD_STATE)

        # set the end of period to the future so we are currently in
        period = survey_logic.Period(end=timeline_utils.future())
        self.assertEqual(period.state, survey_logic.IN_PERIOD_STATE)
Beispiel #45
0
    def testForRightUnboundPeriod(self):
        """Tests state for periods with no end date."""
        # set the start of period to the past so that we are currently in
        period = survey_logic.Period(start=timeline_utils.past())
        self.assertEqual(period.state, survey_logic.IN_PERIOD_STATE)

        # set the start of period to the future so that is has yet to start
        period = survey_logic.Period(start=timeline_utils.future())
        self.assertEqual(period.state, survey_logic.PRE_PERIOD_STATE)
Beispiel #46
0
    def testForLeftUnboundPeriod(self):
        """Tests state for periods with no start date."""
        # set the end of period to the past so the period is already over
        period = survey_logic.Period(end=timeline_utils.past())
        self.assertEqual(period.state, survey_logic.POST_PERIOD_STATE)

        # set the end of period to the future so we are currently in
        period = survey_logic.Period(end=timeline_utils.future())
        self.assertEqual(period.state, survey_logic.IN_PERIOD_STATE)
Beispiel #47
0
  def testAfterStudentAppPeriod(self):
    # move the student app period to the future
    self.timeline.student_signup_end = timeline_utils.past()
    self.timeline.put()

    # it is not possible to submit a proposal now
    can_submit = proposal_logic.canSubmitProposal(
        self.student, self.program, self.timeline)
    self.assertFalse(can_submit)
Beispiel #48
0
    def testForRightUnboundPeriod(self):
        """Tests state for periods with no end date."""
        # set the start of period to the past so that we are currently in
        period = survey_logic.Period(start=timeline_utils.past())
        self.assertEqual(period.state, survey_logic.IN_PERIOD_STATE)

        # set the start of period to the future so that is has yet to start
        period = survey_logic.Period(start=timeline_utils.future())
        self.assertEqual(period.state, survey_logic.PRE_PERIOD_STATE)
Beispiel #49
0
  def testAfterStudentAppPeriod(self):
    # move the student app period to the future
    self.timeline.student_signup_end = timeline_utils.past()
    self.timeline.put()

    # it should still be possible to resubmit this proposal
    can_resubmit = proposal_logic.canProposalBeResubmitted(
        self.proposal, self.student, self.program, self.timeline)
    self.assertTrue(can_resubmit)
Beispiel #50
0
 def createOrgApp(self, override=None):
   """Creates an organization application for the defined properties."""
   override = override or {}
   override.update({
       'key_name': 'gsoc_program/%s/orgapp' % self.program.key().name(),
       'survey_start': timeline_utils.past(),
       'survey_end': timeline_utils.future(),
       })
   return super(GSoCProgramHelper, self).createOrgApp(override)
Beispiel #51
0
    def testAfterStudentAppPeriod(self):
        # move the student app period to the future
        self.timeline.student_signup_end = timeline_utils.past()
        self.timeline.put()

        # it should still be possible to resubmit this proposal
        can_resubmit = proposal_logic.canProposalBeResubmitted(
            self.proposal, self.student, self.program, self.timeline)
        self.assertTrue(can_resubmit)
Beispiel #52
0
    def testForExtensionWithStartAndEndDate(self):
        """Tests active period if there is an extension with start and end date."""
        self.survey.survey_start = timeline_utils.past(delta=100)
        self.survey.survey_end = timeline_utils.future(delta=100)

        # test for an extension that is within the survey period
        self.extension.start_date = self.survey.survey_start + timedelta(1)
        self.extension.end_date = self.survey.survey_end - timedelta(1)

        # active period should be the same as for the survey
        period = survey_logic.getSurveyActivePeriod(self.survey,
                                                    self.extension)
        self.assertEquals(period.start, self.survey.survey_start)
        self.assertEquals(period.end, self.survey.survey_end)

        # test for an extension which is a superset of the survey
        self.extension.start_date = self.survey.survey_start - timedelta(1)
        self.extension.end_date = self.survey.survey_end + timedelta(1)

        # active period should be the same as for the extension
        period = survey_logic.getSurveyActivePeriod(self.survey,
                                                    self.extension)
        self.assertEquals(period.start, self.extension.start_date)
        self.assertEquals(period.end, self.extension.end_date)

        # test for an extension which starts earlier than the survey and ends
        # before the survey ends
        self.extension.start_date = self.survey.survey_start - timedelta(1)
        self.extension.end_date = self.survey.survey_end - timedelta(1)

        # active period should start as extension starts and ends as survey ends
        period = survey_logic.getSurveyActivePeriod(self.survey,
                                                    self.extension)
        self.assertEquals(period.start, self.extension.start_date)
        self.assertEquals(period.end, self.survey.survey_end)

        # test for an extension which starts after than the survey and ends
        # before the survey ends
        self.extension.start_date = self.survey.survey_start + timedelta(1)
        self.extension.end_date = self.survey.survey_end + timedelta(1)

        # active period should start when survey starts and end when extension ends
        period = survey_logic.getSurveyActivePeriod(self.survey,
                                                    self.extension)
        self.assertEquals(period.start, self.survey.survey_start)
        self.assertEquals(period.end, self.extension.end_date)

        # test for an extension that does not overlap with the survey dates
        self.extension.start_date = self.survey.survey_start - timedelta(10)
        self.extension.end_date = self.survey.survey_start - timedelta(5)

        # active period should span between extension start and survey end
        period = survey_logic.getSurveyActivePeriod(self.survey,
                                                    self.extension)
        self.assertEquals(period.start, self.extension.start_date)
        self.assertEquals(period.end, self.survey.survey_end)
Beispiel #53
0
    def testAfterStudentAppPeriod(self):
        # move the student app period to the future
        self.timeline.student_signup_end = timeline_utils.past()
        self.timeline.put()

        # it is not possible to submit a proposal now
        can_submit = proposal_logic.canSubmitProposal(self.student,
                                                      self.program,
                                                      self.timeline)
        self.assertFalse(can_submit)
Beispiel #54
0
    def testDuringStudentSignupAccessGranted(self):
        """Tests that access is granted during student sign-up period."""
        self.program.timeline.student_signup_start = timeline_utils.past(
            delta=10)
        self.program.timeline.student_signup_end = timeline_utils.future(
            delta=10)
        self.program.timeline.put()

        access_checker = access.StudentSignupActiveAccessChecker()
        access_checker.checkAccess(self.data, None)
  def testBeforeOrgSignupStart(self):
    """Tests for beforeOrgSignupStart function."""
    # organization application has yet to start
    self.timeline_helper.org_app.survey_start = timeline_utils.future(delta=1)
    self.timeline_helper.org_app.survey_end = timeline_utils.future(delta=2)
    self.assertTrue(self.timeline_helper.beforeOrgSignupStart())

    # organization application has started
    self.timeline_helper.org_app.survey_start = timeline_utils.past(delta=1)
    self.timeline_helper.org_app.survey_end = timeline_utils.future(delta=2)
    self.assertFalse(self.timeline_helper.beforeOrgSignupStart())

    # organization application has ended
    self.timeline_helper.org_app.survey_start = timeline_utils.past(delta=2)
    self.timeline_helper.org_app.survey_end = timeline_utils.past(delta=1)
    self.assertFalse(self.timeline_helper.beforeOrgSignupStart())

    # no organization application is defined
    self.timeline_helper.org_app = None
    self.assertTrue(self.timeline_helper.beforeOrgSignupStart())
Beispiel #56
0
 def getOrgAppCreatePostData(self):
   """Returns the post data dictionary for creating or editing org app."""
   time_fmt = '%Y-%m-%d %H:%M:%S'
   return {
       'title': 'GSoC Org App',
       'short_name': 'GSoCOA',
       'content': 'Organization application for GSoC',
       'survey_start': timeline_utils.past().strftime(time_fmt),
       'survey_end': timeline_utils.future().strftime(time_fmt),
       'schema': json.dumps(ORG_APP_SCHEMA),
       }
Beispiel #57
0
 def createOrgApp(self, override=None):
     """Creates an organization application for the defined properties."""
     override = override or {}
     override.update({
         'key_name':
         'gsoc_program/%s/orgapp' % self.program.key().name(),
         'survey_start':
         timeline_utils.past(),
         'survey_end':
         timeline_utils.future(),
     })
     return super(GSoCProgramHelper, self).createOrgApp(override)
Beispiel #58
0
    def testSurveyHasStartedWithExtension(self):
        """Tests for survey that has started only with an extension."""
        # survey has not started yet
        self.survey.survey_start = timeline_utils.future(delta=100)
        self.survey.survey_end = timeline_utils.future(delta=200)

        # seed an extension
        self.extension = survey_model.PersonalExtension(parent=self.profile.key, survey=self.survey_key)
        self.extension.start_date = timeline_utils.past()
        self.extension.put()

        result = survey_logic.hasSurveyStarted(self.survey, self.profile.key)
        self.assertTrue(result)
  def createSurveys(self):
    """Creates the surveys and records required for the tests in the old
    format.
    """
    user = profile_utils.seedNDBUser()
    survey_values = {
        'author': user.key.to_old_key(),
        'title': 'Title',
        'modified_by': user.key.to_old_key(),
        'link_id': 'link_id',
        'scope': self.program,
        'survey_start': timeline_utils.past(),
        'survey_end': timeline_utils.past(),
    }

    self.project_survey = ProjectSurvey(
        key_name='key_name', **survey_values)
    self.project_survey.put()

    self.grading_survey = GradingProjectSurvey(
        key_name='key_name', **survey_values)
    self.grading_survey.put()