Ejemplo n.º 1
0
 def test_model_with_valid_composite_entity(self):
     # Value has the form: "[entity_type].[entity_id].[entity_version]".
     model = improvements_models.TaskEntryModel(
         id='23',
         entity_id='999',
         entity_type='exploration',
         entity_version=2,
         target_id='888',
         target_type='state',
         task_type='high_bounce_rate',
         status='open',
         composite_entity_id='exploration.999.2',
         created_on=self.NOW,
         last_updated=self.NOW,
     )
     output = (self.pipeline
               | beam.Create([model])
               | beam.ParDo(
                   improvements_validation.ValidateCompositeEntityId()))
     self.assert_pcoll_equal(output, [])
Ejemplo n.º 2
0
 def test_model_with_invalid_composite_entity(self):
     model = improvements_models.TaskEntryModel(
         id='123',
         entity_id='999',
         entity_type='exploration',
         entity_version=2,
         target_id='888',
         target_type='state',
         task_type='high_bounce_rate',
         status='open',
         composite_entity_id='invalid_id',
         created_on=self.NOW,
         last_updated=self.NOW,
     )
     output = (self.pipeline
               | beam.Create([model])
               | beam.ParDo(
                   improvements_validation.ValidateCompositeEntityId()))
     self.assert_pcoll_equal(output, [
         improvements_validation_errors.InvalidCompositeEntityError(model)
     ])