示例#1
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)
示例#2
0
 def setPersonalExtensionTxn():
     """Transaction to set personal extension."""
     start_date = form.cleaned_data['start_date']
     end_date = form.cleaned_data['end_date']
     survey_logic.createOrUpdatePersonalExtension(profile_key,
                                                  survey_key,
                                                  start_date=start_date,
                                                  end_date=end_date)
示例#3
0
 def testExtensionDoesNotExist(self):
     """Tests that extension is created when it does not exist."""
     extension = survey_logic.createOrUpdatePersonalExtension(
         self.profile.key, self.survey.key())
     self.assertIsNotNone(extension)
     self.assertEqual(extension.key.parent(), self.profile.key)
     self.assertEqual(extension.survey, self.survey_key)
示例#4
0
    def testExtensionAreadyExists(self):
        """Tests that another extension is not created if one exists."""
        extension = survey_model.PersonalExtension(parent=self.profile.key, survey=self.survey_key)
        extension.put()

        result = survey_logic.createOrUpdatePersonalExtension(self.profile.key, self.survey.key())

        # check that result and extension are the same entity
        self.assertEqual(extension.key, result.key)
示例#5
0
    def testExtensionAreadyExists(self):
        """Tests that another extension is not created if one exists."""
        extension = survey_model.PersonalExtension(parent=self.profile.key,
                                                   survey=self.survey_key)
        extension.put()

        result = survey_logic.createOrUpdatePersonalExtension(
            self.profile.key, self.survey.key())

        # check that result and extension are the same entity
        self.assertEqual(extension.key, result.key)
示例#6
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)
示例#7
0
 def setPersonalExtensionTxn():
   """Transaction to set personal extension."""
   start_date = form.cleaned_data['start_date']
   end_date = form.cleaned_data['end_date']
   survey_logic.createOrUpdatePersonalExtension(
       profile_key, survey_key, start_date=start_date, end_date=end_date)
示例#8
0
 def testExtensionDoesNotExist(self):
     """Tests that extension is created when it does not exist."""
     extension = survey_logic.createOrUpdatePersonalExtension(self.profile.key, self.survey.key())
     self.assertIsNotNone(extension)
     self.assertEqual(extension.key.parent(), self.profile.key)
     self.assertEqual(extension.survey, self.survey_key)