Ejemplo n.º 1
0
    def test_reports_model_last_updated_timestamp_relationship_error(
            self
    ) -> None:
        invalid_timestamp = blog_models.BlogPostModel(
            id='validblogid1',
            title='Sample Title',
            content='<p>hello</p>,',
            author_id='user',
            url_fragment='url-fragment-1',
            created_on=self.YEAR_AGO,
            last_updated=self.YEAR_AGO,
            published_on=self.NOW)

        output = (
            self.pipeline
            | beam.Create([invalid_timestamp])
            | beam.ParDo(blog_validation.ValidateModelPublishTimestamps())
        )

        self.assert_pcoll_equal( # type: ignore[no-untyped-call]
            output, [
                blog_validation_errors
                .InconsistentPublishLastUpdatedTimestampsError(
                    invalid_timestamp),
            ]
        )
Ejemplo n.º 2
0
    def test_process_reports_no_error_if_published_on_is_none(self) -> None:
        valid_timestamp = blog_models.BlogPostModel(
            id='124',
            title='Sample Title',
            content='<p>hello</p>,',
            author_id='user',
            url_fragment='url-fragment-1',
            created_on=self.NOW,
            last_updated=self.NOW,
            published_on=None)

        output = (self.pipeline
                  | beam.Create([valid_timestamp])
                  | beam.ParDo(
                      blog_validation.ValidateModelPublishTimestamps()))

        self.assert_pcoll_equal(output, [])
Ejemplo n.º 3
0
    def test_process_reports_model_mutated_during_job_error(self) -> None:
        invalid_timestamp = blog_models.BlogPostModel(
            id='124',
            title='Sample Title',
            content='<p>hello</p>,',
            author_id='user',
            url_fragment='url-fragment-1',
            created_on=self.NOW,
            last_updated=self.YEAR_LATER,
            published_on=self.YEAR_LATER)

        output = (self.pipeline
                  | beam.Create([invalid_timestamp])
                  | beam.ParDo(
                      blog_validation.ValidateModelPublishTimestamps()))

        self.assert_pcoll_equal(output, [
            blog_validation_errors.ModelMutatedDuringJobError(
                invalid_timestamp),
        ])