Beispiel #1
0
    def test_raises_commit_cmd_none_error(self):
        # type: () -> None
        invalid_commit_cmd_model = (story_models.StoryCommitLogEntryModel(
            id='model_id123',
            created_on=self.YEAR_AGO,
            last_updated=self.NOW,
            story_id='story-id',
            user_id='user-id',
            commit_type='test-type',
            post_commit_status='private',
            commit_cmds=[{
                'cmd': base_models.VersionedModel.CMD_DELETE_COMMIT
            }]))

        output = (self.pipeline
                  | beam.Create([invalid_commit_cmd_model])
                  | beam.ParDo(
                      story_validation.ValidateStoryCommitLogEntryModel()))

        self.assert_pcoll_equal(  # type: ignore[no-untyped-call]
            output,
            [
                base_validation_errors.
                CommitCmdsNoneError(  # type: ignore[no-untyped-call]
                    invalid_commit_cmd_model)
            ])
    def test_validate_story_model(self) -> None:
        valid_commit_cmd_model = (story_models.StoryCommitLogEntryModel(
            id='story_id123',
            created_on=self.YEAR_AGO,
            last_updated=self.NOW,
            story_id='story-id',
            user_id='user-id',
            commit_type='test-type',
            post_commit_status='private',
            commit_cmds=[{
                'cmd': base_models.VersionedModel.CMD_DELETE_COMMIT
            }]))

        output = (self.pipeline
                  | beam.Create([valid_commit_cmd_model])
                  | beam.ParDo(
                      story_validation.ValidateStoryCommitLogEntryModel()))

        self.assert_pcoll_equal(output, [])