Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions tests/unit/vertexai/genai/replays/test_delete_prompt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pylint: disable=protected-access,bad-continuation,missing-function-docstring

import logging

from tests.unit.vertexai.genai.replays import pytest_helper
from vertexai._genai import types
from google.genai import types as genai_types

TEST_PROMPT_DATASET_ID = "6550997480673116160"
TEST_PROMPT_VERSION_ID = "2"


def test_delete_dataset(client, caplog):
caplog.set_level(logging.INFO)
prompt = client.prompt_management.create_version(
prompt=types.Prompt(
prompt_data=types.PromptData(
model="gemini-2.5-flash",
contents=[
genai_types.Content(
parts=[genai_types.Part(text="What is the capital of France?")],
)
],
)
),
config=types.CreatePromptConfig(
prompt_display_name="test_delete_prompt_dataset",
version_display_name="test_delete_prompt_dataset_version",
),
)
client.prompt_management.delete_prompt(
prompt_id=prompt.prompt_id,
)
assert "Deleted prompt with id: " in caplog.text


def test_delete_dataset_version(client, caplog):
caplog.set_level(logging.INFO)
prompt = client.prompt_management.create_version(
prompt=types.Prompt(
prompt_data=types.PromptData(
model="gemini-2.5-flash",
contents=[
genai_types.Content(
parts=[genai_types.Part(text="What is the capital of France?")],
)
],
)
),
config=types.CreatePromptConfig(
prompt_display_name="test_delete_prompt_dataset",
version_display_name="test_delete_prompt_dataset_version",
),
)
version_id = prompt.dataset_version.name.split("/")[-1]
client.prompt_management.delete_version(
prompt_id=prompt.prompt_id,
version_id=version_id,
)
assert "Deleted prompt version" in caplog.text


pytestmark = pytest_helper.setup(
file=__file__,
globals_for_file=globals(),
test_method="prompt_management.delete",
)
Loading
Loading