1+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+ from __future__ import annotations
4+
5+ import subprocess
6+ import json
7+ import os
8+
9+ base_url = os .environ .get ("TEST_API_BASE_URL" , "http://127.0.0.1:4010" )
10+
11+ def run_command (command : str ) -> subprocess .CompletedProcess [str ]:
12+ return subprocess .run (["together" , "--base-url" , base_url , "endpoints" , * command .split (" " ), "--json" ], capture_output = True , text = True )
13+
14+ def assert_command_returns_json (command : str ) -> None :
15+ result = run_command (command )
16+ assert result .returncode == 0
17+ assert result .stdout is not None
18+ assert json .loads (result .stdout ) is not None
19+
20+ class TestEndpoints :
21+ def test_json_mode_is_supported (self ) -> None :
22+ assert_command_returns_json ("hardware" )
23+ assert_command_returns_json ("hardware --model deepseek-ai/DeepSeek-R1" )
24+ assert_command_returns_json ("availability-zones" )
25+ assert_command_returns_json ("list" )
26+ assert_command_returns_json ("list --type dedicated" )
27+ assert_command_returns_json ("list --usage-type on-demand" )
28+ assert_command_returns_json ("list --usage-type reserved" )
29+ assert_command_returns_json ("list --mine" )
30+ assert_command_returns_json ("create --model deepseek-ai/DeepSeek-R1 --hardware 1x_nvidia_a100_80gb_sxm" )
31+ assert_command_returns_json ("delete endpoint-123" )
32+ assert_command_returns_json ("start endpoint-123" )
33+ assert_command_returns_json ("stop endpoint-123" )
34+ assert_command_returns_json ("retrieve endpoint-123" )
35+ assert_command_returns_json ("update endpoint-123 --min-replicas 2 --max-replicas 4 --inactive-timeout 60" )
36+
37+ def test_create_requires_model (self ) -> None :
38+ result = run_command ("create" )
39+ assert result .returncode == 2
40+ assert "Error: Missing option '--model'." in result .stderr
41+
42+ def test_create_requires_hardware (self ) -> None :
43+ result = run_command ("create --model deepseek-ai/DeepSeek-R1 --hardware ''" )
44+ assert result .returncode == 1
45+ assert "Invalid hardware selected." in result .stderr
0 commit comments