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, []) # type: ignore[no-untyped-call]
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( # type: ignore[no-untyped-call] output, [ blog_validation_errors.ModelMutatedDuringJobError( invalid_timestamp), ])
def test_reports_model_created_on_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.NOW, last_updated=self.YEAR_AGO, published_on=self.YEAR_AGO) 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.InconsistentPublishTimestampsError( invalid_timestamp), ])