-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_get_server_information.py
57 lines (48 loc) · 1.94 KB
/
test_get_server_information.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import json
import os
import pytest
import pandas as pd
import dotenv
import swan
@pytest.fixture
def setup_swan_orchestrator():
# Load environment variables from the .env file
dotenv.load_dotenv()
# Initialize the Swan Orchestrator with API key and network
swan_orchestrator = swan.resource(api_key=os.getenv("SWAN_API_KEY"), network='mainnet', service_name='Orchestrator')
return swan_orchestrator
def test_get_hardware_id_list(setup_swan_orchestrator):
swan_orchestrator = setup_swan_orchestrator
available_hardware = swan_orchestrator.get_hardware_config()
# Process JSON data into a DataFrame
rows = []
for instance in available_hardware:
if isinstance(instance["region"], list): # Check if region is a list
for region in instance["region"]:
rows.append({
"ID": instance["id"],
"Name": instance["name"],
"Description": instance["description"],
"Type": instance["type"],
"Region": region,
"Price": instance["price"],
"Status": instance["status"]
})
else:
# Handle the case where region is a string or other type
rows.append({
"ID": instance["id"],
"Name": instance["name"],
"Description": instance["description"],
"Type": instance["type"],
"Region": instance["region"], # Just take the string directly
"Price": instance["price"],
"Status": instance["status"]
})
df = pd.DataFrame(rows)
# Display the DataFrame as a table
print(df)
def test_get_task_infot(setup_swan_orchestrator):
swan_orchestrator = setup_swan_orchestrator
task_info = swan_orchestrator.get_deployment_info(task_uuid="5f9d2925-bf55-4cb3-b829-20935b011ce1")
print(json.dumps(task_info, indent=2))