def setUp(self) -> None: """Set up user models in datastore for use in testing.""" super(FeedbackThreadModelTest, self).setUp() user_models.UserSettingsModel( id=self.NEW_USER_1_ID, email='*****@*****.**' ).put() user_models.UserSettingsModel( id=self.NEW_USER_2_ID, email='*****@*****.**' ).put() self.feedback_thread_model = feedback_models.GeneralFeedbackThreadModel( id='%s.%s.%s' % (self.ENTITY_TYPE, self.ENTITY_ID, 'random'), entity_type=self.ENTITY_TYPE, entity_id=self.ENTITY_ID, original_author_id=self.USER_ID, status=self.STATUS, subject=self.SUBJECT, has_suggestion=self.HAS_SUGGESTION, summary=self.SUMMARY, message_count=self.MESSAGE_COUNT ) self.feedback_thread_model.update_timestamps() self.feedback_thread_model.put()
def test_model_with_valid_entity_type_raises_no_error(self) -> None: model = feedback_models.GeneralFeedbackThreadModel( id='123', entity_id='123', subject='test_subject', entity_type='exploration', created_on=self.NOW, last_updated=self.NOW, ) output = (self.pipeline | beam.Create([model]) | beam.ParDo(feedback_validation.ValidateEntityType())) self.assert_pcoll_equal(output, [])
def test_message(self) -> None: model = feedback_models.GeneralFeedbackThreadModel( id='123', entity_id='123', subject='test_subject', entity_type='invalid', created_on=self.NOW, last_updated=self.NOW, ) error = feedback_validation_errors.InvalidEntityTypeError(model) self.assertEqual( error.stderr, 'InvalidEntityTypeError in GeneralFeedbackThreadModel(id="123"):' ' entity type %s is invalid.' % model.entity_type)