Ejemplo n.º 1
0
 def test_model_with_valid_draft_change_list_last_updated(self) -> None:
     model = user_models.ExplorationUserDataModel(
         id='123',
         user_id=self.VALID_USER_ID,
         exploration_id=self.VALID_EXPLORATION_ID,
         draft_change_list=self.VALID_DRAFT_CHANGE_LIST,
         draft_change_list_last_updated=(
             self.NOW - datetime.timedelta(days=2)),
         created_on=self.NOW - datetime.timedelta(days=3),
         last_updated=self.NOW - datetime.timedelta(days=2)
     )
     output = (
         self.pipeline
         | beam.Create([model])
         | beam.ParDo(user_validation.ValidateDraftChangeListLastUpdated())
     )
     self.assert_pcoll_equal(output, [])
Ejemplo n.º 2
0
 def test_model_with_draft_change_list_but_no_last_updated(self) -> None:
     model = user_models.ExplorationUserDataModel(
         id='123',
         user_id=self.VALID_USER_ID,
         exploration_id=self.VALID_EXPLORATION_ID,
         draft_change_list=self.VALID_DRAFT_CHANGE_LIST,
         draft_change_list_last_updated=None,
         created_on=self.NOW,
         last_updated=self.NOW
     )
     output = (
         self.pipeline
         | beam.Create([model])
         | beam.ParDo(user_validation.ValidateDraftChangeListLastUpdated())
     )
     self.assert_pcoll_equal(output, [
         user_validation_errors.DraftChangeListLastUpdatedNoneError(model)
     ])
Ejemplo n.º 3
0
    def test_message(self) -> None:
        draft_change_list = [{
            'cmd': 'edit_exploration_property',
            'property_name': 'objective',
            'new_value': 'the objective'
        }]
        model = user_models.ExplorationUserDataModel(
            id='123',
            user_id='test',
            exploration_id='exploration_id',
            draft_change_list=draft_change_list,
            draft_change_list_last_updated=None,
            created_on=self.YEAR_AGO,
            last_updated=self.YEAR_AGO)
        error = (
            user_validation_errors.DraftChangeListLastUpdatedNoneError(model))

        self.assertEqual(
            error.stderr,
            'DraftChangeListLastUpdatedNoneError in ExplorationUserDataModel'
            '(id="123"): draft change list %s exists but draft change list '
            'last updated is None' % draft_change_list)
Ejemplo n.º 4
0
    def test_message(self) -> None:
        draft_change_list = [{
            'cmd': 'edit_exploration_property',
            'property_name': 'objective',
            'new_value': 'the objective'
        }]
        last_updated = self.NOW + datetime.timedelta(days=5)
        model = user_models.ExplorationUserDataModel(
            id='123',
            user_id='test',
            exploration_id='exploration_id',
            draft_change_list=draft_change_list,
            draft_change_list_last_updated=last_updated,
            created_on=self.YEAR_AGO,
            last_updated=self.NOW)
        error = (user_validation_errors.DraftChangeListLastUpdatedInvalidError(
            model))

        self.assertEqual(
            error.stderr, 'DraftChangeListLastUpdatedInvalidError in '
            'ExplorationUserDataModel(id="123"): draft change list last '
            'updated %s is greater than the time when job was run' %
            last_updated)