Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 24c3f2d

Browse files
author
Harry Le
committed
test: reorganize folder
1 parent 66a5cc7 commit 24c3f2d

29 files changed

+210
-267
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import pytest
2+
import requests
3+
import time
4+
from utils.test_runner import (
5+
start_server,
6+
stop_server,
7+
wait_for_websocket_download_success_event,
8+
)
9+
10+
class TestApiEngine:
11+
12+
@pytest.fixture(autouse=True)
13+
def setup_and_teardown(self):
14+
# Setup
15+
success = start_server()
16+
if not success:
17+
raise Exception("Failed to start server")
18+
19+
yield
20+
21+
# Teardown
22+
stop_server()
23+
24+
# engines get
25+
def test_engines_get_llamacpp_should_be_successful(self):
26+
response = requests.get("http://localhost:3928/engines/llama-cpp")
27+
assert response.status_code == 200
28+
29+
# engines install
30+
def test_engines_install_llamacpp_specific_version_and_variant(self):
31+
data = {"version": "v0.1.40-b4354", "variant": "linux-amd64-avx-cuda-11-7"}
32+
response = requests.post(
33+
"http://localhost:3928/v1/engines/llama-cpp/install", json=data
34+
)
35+
assert response.status_code == 200
36+
37+
def test_engines_install_llamacpp_specific_version_and_null_variant(self):
38+
data = {"version": "v0.1.40-b4354"}
39+
response = requests.post(
40+
"http://localhost:3928/v1/engines/llama-cpp/install", json=data
41+
)
42+
assert response.status_code == 200
43+
44+
# engines uninstall
45+
@pytest.mark.asyncio
46+
async def test_engines_install_uninstall_llamacpp_should_be_successful(self):
47+
response = requests.post("http://localhost:3928/v1/engines/llama-cpp/install")
48+
assert response.status_code == 200
49+
await wait_for_websocket_download_success_event(timeout=None)
50+
time.sleep(30)
51+
52+
response = requests.delete("http://localhost:3928/v1/engines/llama-cpp/install")
53+
assert response.status_code == 200
54+
55+
@pytest.mark.asyncio
56+
async def test_engines_install_uninstall_llamacpp_with_only_version_should_be_failed(self):
57+
# install first
58+
data = {"variant": "mac-arm64"}
59+
install_response = requests.post(
60+
"http://127.0.0.1:3928/v1/engines/llama-cpp/install", json=data
61+
)
62+
await wait_for_websocket_download_success_event(timeout=120)
63+
assert install_response.status_code == 200
64+
65+
data = {"version": "v0.1.35"}
66+
response = requests.delete(
67+
"http://localhost:3928/v1/engines/llama-cpp/install", json=data
68+
)
69+
assert response.status_code == 400
70+
assert response.json()["message"] == "No variant provided"
71+
72+
@pytest.mark.asyncio
73+
async def test_engines_install_uninstall_llamacpp_with_variant_should_be_successful(self):
74+
# install first
75+
data = {"variant": "mac-arm64"}
76+
install_response = requests.post(
77+
"http://127.0.0.1:3928/v1/engines/llama-cpp/install", json=data
78+
)
79+
await wait_for_websocket_download_success_event(timeout=120)
80+
assert install_response.status_code == 200
81+
82+
response = requests.delete("http://127.0.0.1:3928/v1/engines/llama-cpp/install")
83+
assert response.status_code == 200
84+
85+
def test_engines_install_uninstall_llamacpp_with_specific_variant_and_version_should_be_successful(
86+
self,
87+
):
88+
data = {"variant": "mac-arm64", "version": "v0.1.35"}
89+
# install first
90+
install_response = requests.post(
91+
"http://localhost:3928/v1/engines/llama-cpp/install", json=data
92+
)
93+
assert install_response.status_code == 200
94+
95+
response = requests.delete(
96+
"http://localhost:3928/v1/engines/llama-cpp/install", json=data
97+
)
98+
assert response.status_code == 200
99+
100+

engine/e2e-test/test_api_engine_install_nightly.py renamed to engine/e2e-test/api/engines/test_api_engine_install_nightly.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22
import requests
3-
from test_runner import start_server, stop_server, get_latest_pre_release_tag
3+
from utils.test_runner import start_server, stop_server, get_latest_pre_release_tag
44

55
latest_pre_release_tag = get_latest_pre_release_tag("janhq", "cortex.llamacpp")
66

engine/e2e-test/test_api_engine_list.py renamed to engine/e2e-test/api/engines/test_api_engine_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22
import requests
3-
from test_runner import start_server, stop_server
3+
from utils.test_runner import start_server, stop_server
44

55

66
class TestApiEngineList:

engine/e2e-test/test_api_engine_update.py renamed to engine/e2e-test/api/engines/test_api_engine_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22
import requests
3-
from test_runner import (
3+
from utils.test_runner import (
44
start_server,
55
stop_server,
66
wait_for_websocket_download_success_event,

engine/e2e-test/test_api_cortexso_hub_llamacpp_engine.py renamed to engine/e2e-test/api/hub/test_api_cortexso_hub_llamacpp_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import yaml
55

66
from pathlib import Path
7-
from test_runner import (
7+
from utils.test_runner import (
88
run,
99
start_server,
1010
stop_server,

engine/e2e-test/test_api_docker.py renamed to engine/e2e-test/api/model/test_api_docker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22
import requests
3-
from test_runner import wait_for_websocket_download_success_event
3+
from utils.test_runner import wait_for_websocket_download_success_event
44

55
repo_branches = ["tinyllama:1b-gguf"]
66

engine/e2e-test/test_api_model.py renamed to engine/e2e-test/api/model/test_api_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
import requests
33
import time
4-
from test_runner import (
4+
from utils.test_runner import (
55
run,
66
start_server,
77
stop_server,

engine/e2e-test/test_api_model_import.py renamed to engine/e2e-test/api/model/test_api_model_import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22
import requests
3-
from test_runner import start_server, stop_server
3+
from utils.test_runner import start_server, stop_server
44

55
class TestApiModelImport:
66
@pytest.fixture(autouse=True)

engine/e2e-test/test_cli_server_start.py renamed to engine/e2e-test/cli/common/test_cli_server_start.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import platform
22
import os
33
import pytest, requests
4-
from test_runner import run
5-
from test_runner import start_server, stop_server
4+
from utils.test_runner import run
5+
from utils.test_runner import start_server, stop_server
66

77

88
class TestCliServerStart:

engine/e2e-test/test_cortex_update.py renamed to engine/e2e-test/cli/common/test_cortex_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import tempfile
33

44
import pytest
5-
from test_runner import run
5+
from utils.test_runner import run
66

77

88
class TestCortexUpdate:

0 commit comments

Comments
 (0)