mirror of
https://github.com/Balshgit/gpt_chat_bot.git
synced 2026-02-03 11:40:39 +03:00
add api exception handler (#74)
* try to add exception handler * improve server error test * fix lint * add build_uri util * fix header file path --------- Co-authored-by: Dmitry Afanasyev <afanasiev@litres.ru>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import time
|
||||
from typing import Callable
|
||||
|
||||
from core.utils import timed_lru_cache
|
||||
import pytest
|
||||
|
||||
from core.utils import build_uri, timed_lru_cache
|
||||
|
||||
|
||||
class TestTimedLruCache:
|
||||
@@ -58,3 +60,21 @@ class TestTimedLruCache:
|
||||
) -> None:
|
||||
for _ in range(call_times):
|
||||
assert func(first, second) == result
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"uri_parts, expected_result",
|
||||
[
|
||||
(["", "admin"], "/admin"),
|
||||
(["/gpt", "admin"], "/gpt/admin"),
|
||||
(["/gpt", "/chat"], "/gpt/chat"),
|
||||
(["gpt", ""], "/gpt"),
|
||||
(["gpt"], "/gpt"),
|
||||
(["gpt", "chat"], "/gpt/chat"),
|
||||
(["", ""], "/"),
|
||||
(["gpt", "/chat", "/admin"], "/gpt/chat/admin"),
|
||||
(["gpt/", "/chat/", "/admin"], "/gpt/chat/admin"),
|
||||
],
|
||||
)
|
||||
def test_build_uri_with_slash_prefix(uri_parts: list[str], expected_result: str) -> None:
|
||||
assert build_uri(uri_parts) == expected_result
|
||||
|
||||
Reference in New Issue
Block a user