11import pytest
22import requests
3- from test_runner import start_server , stop_server
3+ from test_runner import (
4+ run ,
5+ start_server ,
6+ stop_server ,
7+ wait_for_websocket_download_success_event ,
8+ )
49
510
611class TestApiEngineUninstall :
@@ -18,47 +23,56 @@ def setup_and_teardown(self):
1823 stop_server ()
1924
2025 def test_engines_uninstall_llamacpp_should_be_successful (self ):
21- # install first
22- requests .post ("http://localhost:3928/v1/engines/llama-cpp" )
23-
24- response = requests .delete ("http://localhost:3928/v1/engines/llama-cpp" )
26+ # install first, using cli for synchronously
27+ run (
28+ "Install Engine" ,
29+ ["engines" , "install" , "llama-cpp" ],
30+ timeout = 120 ,
31+ capture = False ,
32+ )
33+ response = requests .delete ("http://localhost:3928/v1/engines/llama-cpp/install" )
2534 assert response .status_code == 200
2635
2736 def test_engines_uninstall_llamacpp_with_only_version_should_be_failed (self ):
2837 # install first
29- install_response = requests .post (
30- "http://localhost:3928/v1/engines/llama-cpp?version=v0.1.35"
38+ run (
39+ "Install Engine" ,
40+ ["engines" , "install" , "llama-cpp" , "-v" , "v0.1.35" ],
41+ timeout = None ,
42+ capture = False ,
3143 )
32- assert install_response .status_code == 200
3344
45+ data = {"version" : "v0.1.35" }
3446 response = requests .delete (
35- "http://localhost:3928/v1/engines/llama-cpp?version=v0.1.35"
47+ "http://localhost:3928/v1/engines/llama-cpp/install" , json = data
3648 )
3749 assert response .status_code == 400
3850 assert response .json ()["message" ] == "No variant provided"
3951
40- def test_engines_uninstall_llamacpp_with_variant_should_be_successful (self ):
52+ @pytest .mark .asyncio
53+ async def test_engines_uninstall_llamacpp_with_variant_should_be_successful (self ):
4154 # install first
55+ data = {"variant" : "mac-arm64" }
4256 install_response = requests .post (
43- "http://localhost :3928/v1/engines/llama-cpp?variant=mac-arm64"
57+ "http://127.0.0.1 :3928/v1/engines/llama-cpp/install" , json = data
4458 )
59+ await wait_for_websocket_download_success_event (timeout = 120 )
4560 assert install_response .status_code == 200
4661
47- response = requests .delete (
48- "http://localhost:3928/v1/engines/llama-cpp?variant=mac-arm64"
49- )
62+ response = requests .delete ("http://127.0.0.1:3928/v1/engines/llama-cpp/install" )
5063 assert response .status_code == 200
5164
5265 def test_engines_uninstall_llamacpp_with_specific_variant_and_version_should_be_successful (
5366 self ,
5467 ):
68+ data = {"variant" : "mac-arm64" , "version" : "v0.1.35" }
5569 # install first
5670 install_response = requests .post (
57- "http://localhost:3928/v1/engines/llama-cpp?variant=mac-arm64&version=v0.1.35"
71+ "http://localhost:3928/v1/engines/llama-cpp/install" , json = data
5872 )
5973 assert install_response .status_code == 200
6074
6175 response = requests .delete (
62- "http://localhost:3928/v1/engines/llama-cpp?variant=mac-arm64&version=v0.1.35"
76+ "http://localhost:3928/v1/engines/llama-cpp/install" , json = data
6377 )
6478 assert response .status_code == 200
0 commit comments