Ejemplo n.º 1
0
    def test_param_change_object_with_invalid_cmd_raises_exception(self):
        invalid_commit_cmd_model = (
            config_models.PlatformParameterSnapshotMetadataModel(
                id='model_id-1',
                created_on=self.YEAR_AGO,
                last_updated=self.NOW,
                committer_id='committer_id',
                commit_type='create',
                commit_cmds_user_ids=[
                    'commit_cmds_user_1_id', 'commit_cmds_user_2_id'],
                content_user_ids=['content_user_1_id', 'content_user_2_id'],
                commit_cmds=[{'cmd': 'invalid'}])
        )

        output = (
            self.pipeline
            | beam.Create([invalid_commit_cmd_model])
            | beam.ParDo(
                config_validation.ValidatePlatformParameterCommitCmdsSchema())
        )

        self.assert_pcoll_equal(output, [
            base_validation_errors.CommitCmdsValidateError(
                invalid_commit_cmd_model,
                {'cmd': 'invalid'},
                'Command invalid is not allowed')
        ])
Ejemplo n.º 2
0
    def test_param_change_object_missing_attribute_in_cmd_raises_exception(
            self):
        invalid_commit_cmd_model = (
            config_models.PlatformParameterSnapshotMetadataModel(
                id='model_id-1',
                created_on=self.YEAR_AGO,
                last_updated=self.NOW,
                committer_id='committer_id',
                commit_type='create',
                commit_cmds_user_ids=[
                    'commit_cmds_user_1_id', 'commit_cmds_user_2_id'],
                content_user_ids=['content_user_1_id', 'content_user_2_id'],
                commit_cmds=[{'cmd': self.CMD_EDIT_RULES}])
        )

        output = (
            self.pipeline
            | beam.Create([invalid_commit_cmd_model])
            | beam.ParDo(
                config_validation.ValidatePlatformParameterCommitCmdsSchema())
        )

        self.assert_pcoll_equal(output, [
            base_validation_errors.CommitCmdsValidateError(
                invalid_commit_cmd_model,
                {'cmd': self.CMD_EDIT_RULES},
                'The following required attributes are missing: new_rules')
        ])
Ejemplo n.º 3
0
    def test_validate_change_domain_implemented(self):
        invalid_commit_cmd_model = (
            config_models.PlatformParameterSnapshotMetadataModel(
                id='model_id-1',
                created_on=self.YEAR_AGO,
                last_updated=self.NOW,
                committer_id='committer_id',
                commit_type='create',
                commit_cmds_user_ids=[
                    'commit_cmds_user_1_id', 'commit_cmds_user_2_id'],
                content_user_ids=['content_user_1_id', 'content_user_2_id'],
                commit_cmds=[{
                    'cmd': base_models.VersionedModel.CMD_DELETE_COMMIT}])
        )

        output = (
            self.pipeline
            | beam.Create([invalid_commit_cmd_model])
            | beam.ParDo(
                config_validation.ValidatePlatformParameterCommitCmdsSchema())
        )

        self.assert_pcoll_equal(output, [])