def test_message_for_public_post_commit_status(self): model = base_models.BaseCommitLogEntryModel( id='123', created_on=self.YEAR_AGO, last_updated=self.NOW, commit_type='invalid-type', user_id='', post_commit_status='public', post_commit_is_private=True, commit_cmds=[]) error = errors.InvalidCommitStatusError(model) self.assertEqual( error.message, 'InvalidCommitStatusError in BaseCommitLogEntryModel(id="123"): ' 'post_commit_status="public" but post_commit_is_private=True')
def process(self, input_model): """Function validates that post_commit_is_private is true iff post_commit_status is private Args: input_model: base_models.BaseCommitLogEntryModel. Entity to validate. Yields: ModelInvalidCommitStatus. Error for commit_type validation. """ model = jobs_utils.clone_model(input_model) expected_post_commit_is_private = ( model.post_commit_status == feconf.POST_COMMIT_STATUS_PRIVATE) if model.post_commit_is_private != expected_post_commit_is_private: yield errors.InvalidCommitStatusError(model)
def test_validate_post_commit_is_private_when_status_is_private(self): invalid_commit_status = base_models.BaseCommitLogEntryModel( id='123', created_on=self.YEAR_AGO, last_updated=self.NOW, commit_type='invalid-type', user_id='', post_commit_status='private', post_commit_is_private=False, commit_cmds=[]) output = (self.pipeline | beam.Create([invalid_commit_status]) | beam.ParDo( base_model_validator.ValidatePostCommitIsPrivate())) self.assert_pcoll_equal(output, [ errors.InvalidCommitStatusError(invalid_commit_status), ])