Ejemplo n.º 1
0
    def test_validation_type_for_exploration_domain_object(self) -> None:
        model_instance1 = exp_models.ExplorationModel(
            id='mock-123',
            title='title',
            category='category',
            language_code='en',
            init_state_name=feconf.DEFAULT_INIT_STATE_NAME,
            states={
                feconf.DEFAULT_INIT_STATE_NAME: (
                    state_domain.State.create_default_state(  # type: ignore[no-untyped-call]
                        feconf.DEFAULT_INIT_STATE_NAME, is_initial_state=True
                    ).to_dict()),
            },
            states_schema_version=feconf.CURRENT_STATE_SCHEMA_VERSION,
            created_on=self.YEAR_AGO,
            last_updated=self.NOW
        )

        model_instance2 = exp_models.ExplorationModel(
            id='mock-123',
            title='title',
            category='category',
            language_code='en',
            init_state_name=feconf.DEFAULT_INIT_STATE_NAME,
            states={
                feconf.DEFAULT_INIT_STATE_NAME: (
                    state_domain.State.create_default_state(  # type: ignore[no-untyped-call]
                        'end', is_initial_state=True
                    ).to_dict()),
            },
            states_schema_version=feconf.CURRENT_STATE_SCHEMA_VERSION,
            created_on=self.YEAR_AGO,
            last_updated=self.NOW
        )

        output = (
            self.pipeline
            | beam.Create([model_instance1, model_instance2])
            | beam.ParDo(MockValidateExplorationModelDomainObjectInstances())
        )

        self.assert_pcoll_equal(output, [
            base_validation_errors.ModelDomainObjectValidateError(
                model_instance2, 'The destination end is not a valid state.')
        ])
Ejemplo n.º 2
0
 def test_reconstitute(self) -> None:
     exploration = exp_domain.Exploration.create_default_exploration( # type: ignore[no-untyped-call]
         'id', title='A Title',
         category='A Category', objective='An Objective')
     exp_services.save_new_exploration('id', exploration) # type: ignore[no-untyped-call]
     exp_model = exp_models.ExplorationModel.get_by_id('id')
     snapshot_dict = exp_model.compute_snapshot()
     snapshot_dict['skill_tags'] = ['tag1', 'tag2']
     snapshot_dict['default_skin'] = 'conversation_v1'
     snapshot_dict['skin_customizations'] = {}
     snapshot_dict = exp_models.ExplorationModel.convert_to_valid_dict(
         snapshot_dict)
     exp_model = exp_models.ExplorationModel(**snapshot_dict)
     snapshot_dict = exp_model.compute_snapshot()
     for field in ['skill_tags', 'default_skin', 'skin_customization']:
         self.assertNotIn(field, snapshot_dict)