コード例 #1
0
ファイル: exp_validation_test.py プロジェクト: oppia/oppia
    def test_exploration_rights_change_object_with_invalid_status(
        self
    ) -> None:
        invalid_commit_cmd_model = (
            exp_models.ExplorationRightsSnapshotMetadataModel(
                id='model_id-1',
                created_on=self.YEAR_AGO,
                last_updated=self.NOW,
                committer_id='committer_id',
                commit_type='create',
                commit_cmds=[{
                    'cmd': 'change_exploration_status',
                    'old_status': rights_domain.ACTIVITY_STATUS_PRIVATE,
                    'new_status': 'invalid'
                }])
        )

        output = (
            self.pipeline
            | beam.Create([invalid_commit_cmd_model])
            | beam.ParDo(
                exp_validation.ValidateExplorationRightsSnapshotMetadataModel())
        )

        self.assert_pcoll_equal(output, [
            base_validation_errors.CommitCmdsValidateError(
                invalid_commit_cmd_model,
                {
                    'cmd': 'change_exploration_status',
                    'old_status': rights_domain.ACTIVITY_STATUS_PRIVATE,
                    'new_status': 'invalid'
                },
                'Value for new_status in cmd change_exploration_status: '
                'invalid is not allowed')
        ])
コード例 #2
0
ファイル: exp_validation_test.py プロジェクト: oppia/oppia
    def test_exploration_rights_change_object_with_missing_attribute_in_cmd(
        self
    ) -> None:
        invalid_commit_cmd_model = (
            exp_models.ExplorationRightsSnapshotMetadataModel(
                id='model_id-1',
                created_on=self.YEAR_AGO,
                last_updated=self.NOW,
                committer_id='committer_id',
                commit_type='create',
                commit_cmds=[{
                    'cmd': 'change_role',
                    'assignee_id': 'assignee_id',
                }])
        )

        output = (
            self.pipeline
            | beam.Create([invalid_commit_cmd_model])
            | beam.ParDo(
                exp_validation.ValidateExplorationRightsSnapshotMetadataModel())
        )

        self.assert_pcoll_equal(output, [
            base_validation_errors.CommitCmdsValidateError(
                invalid_commit_cmd_model,
                {
                    'cmd': 'change_role',
                    'assignee_id': 'assignee_id',
                },
                'The following required attributes are missing: '
                'new_role, old_role')
        ])
コード例 #3
0
ファイル: exp_validation_test.py プロジェクト: oppia/oppia
    def test_exploration_rights_change_object_with_extra_attribute_in_cmd(
        self
    ) -> None:
        invalid_commit_cmd_model = (
            exp_models.ExplorationRightsSnapshotMetadataModel(
                id='model_id-1',
                created_on=self.YEAR_AGO,
                last_updated=self.NOW,
                committer_id='committer_id',
                commit_type='create',
                commit_cmds=[{
                    'cmd': 'change_private_viewability',
                    'old_viewable_if_private': 'old_viewable_if_private',
                    'new_viewable_if_private': 'new_viewable_if_private',
                    'invalid': 'invalid'
                }])
        )

        output = (
            self.pipeline
            | beam.Create([invalid_commit_cmd_model])
            | beam.ParDo(
                exp_validation.ValidateExplorationRightsSnapshotMetadataModel())
        )

        self.assert_pcoll_equal(output, [
            base_validation_errors.CommitCmdsValidateError(
                invalid_commit_cmd_model,
                {
                    'cmd': 'change_private_viewability',
                    'old_viewable_if_private': 'old_viewable_if_private',
                    'new_viewable_if_private': 'new_viewable_if_private',
                    'invalid': 'invalid'
                },
                'The following extra attributes are present: invalid')
        ])
コード例 #4
0
ファイル: exp_validation_test.py プロジェクト: oppia/oppia
    def test_exploration_rights_change_object_with_invalid_cmd(self) -> None:
        invalid_commit_cmd_model = (
            exp_models.ExplorationRightsSnapshotMetadataModel(
                id='model_id-1',
                created_on=self.YEAR_AGO,
                last_updated=self.NOW,
                committer_id='committer_id',
                commit_type='create',
                commit_cmds=[{'cmd': 'invalid'}])
        )

        output = (
            self.pipeline
            | beam.Create([invalid_commit_cmd_model])
            | beam.ParDo(
                exp_validation.ValidateExplorationRightsSnapshotMetadataModel())
        )

        self.assert_pcoll_equal(output, [
            base_validation_errors.CommitCmdsValidateError(
                invalid_commit_cmd_model,
                {'cmd': 'invalid'},
                'Command invalid is not allowed')
        ])