mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-14 17:03:29 +03:00
tests: Add tests for deleting prompts by ID (#2156)
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
This commit is contained in:
parent
11f76f4e75
commit
2f7e85ceae
@ -1,3 +1,11 @@
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
from modules.prompt.repository.prompts import Prompts
|
||||
from modules.prompt.service.prompt_service import DeletePromptResponse
|
||||
|
||||
|
||||
def test_get_public_prompts(client, api_key):
|
||||
response = client.get(
|
||||
"/prompts",
|
||||
@ -5,3 +13,30 @@ def test_get_public_prompts(client, api_key):
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert len(response.json()) == 0
|
||||
|
||||
|
||||
def test_delete_prompt_by_id():
|
||||
# Arrange
|
||||
prompts = Prompts()
|
||||
prompt_id = uuid.uuid4() # Generate a valid UUID
|
||||
|
||||
# Act
|
||||
result = prompts.delete_prompt_by_id(prompt_id)
|
||||
|
||||
# Assert
|
||||
assert isinstance(result, DeletePromptResponse)
|
||||
assert result.status == "deleted"
|
||||
assert result.prompt_id == prompt_id
|
||||
|
||||
|
||||
def test_delete_prompt_by_id_not_found():
|
||||
# Arrange
|
||||
prompts = Prompts()
|
||||
prompt_id = uuid.uuid4() # Generate a valid UUID
|
||||
|
||||
# Act and Assert
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
prompts.delete_prompt_by_id(prompt_id)
|
||||
|
||||
assert exc_info.value.status_code == 404
|
||||
assert str(exc_info.value.detail) == "Prompt not found"
|
||||
|
Loading…
Reference in New Issue
Block a user