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)
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)
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)
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)
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)
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)
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)
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)