|
| 1 | +import responses # https://github.com/getsentry/responses |
| 2 | + |
| 3 | +from verda.cluster_types import ClusterType, ClusterTypesService |
| 4 | + |
| 5 | +CLUSTER_TYPE_ID = 'cluster-c0de-a5d2-4972-ae4e-d429115d055b' |
| 6 | + |
| 7 | + |
| 8 | +@responses.activate |
| 9 | +def test_cluster_types(http_client): |
| 10 | + endpoint = http_client._base_url + '/cluster-types?currency=usd' |
| 11 | + responses.add( |
| 12 | + responses.GET, |
| 13 | + endpoint, |
| 14 | + json=[ |
| 15 | + { |
| 16 | + 'id': CLUSTER_TYPE_ID, |
| 17 | + 'model': 'H200', |
| 18 | + 'name': 'H200 Cluster', |
| 19 | + 'cluster_type': '16H200', |
| 20 | + 'cpu': {'description': '64 CPU', 'number_of_cores': 64}, |
| 21 | + 'gpu': {'description': '16x H200', 'number_of_gpus': 16}, |
| 22 | + 'gpu_memory': {'description': '2.2TB VRAM', 'size_in_gigabytes': 2200}, |
| 23 | + 'memory': {'description': '4TB RAM', 'size_in_gigabytes': 4096}, |
| 24 | + 'price_per_hour': '45.50', |
| 25 | + 'currency': 'usd', |
| 26 | + 'manufacturer': 'NVIDIA', |
| 27 | + 'node_details': ['2x 8 GPU nodes'], |
| 28 | + 'supported_os': ['ubuntu-24.04-cuda-12.8-cluster'], |
| 29 | + } |
| 30 | + ], |
| 31 | + status=200, |
| 32 | + ) |
| 33 | + |
| 34 | + service = ClusterTypesService(http_client) |
| 35 | + |
| 36 | + cluster_types = service.get() |
| 37 | + cluster_type = cluster_types[0] |
| 38 | + |
| 39 | + assert isinstance(cluster_types, list) |
| 40 | + assert len(cluster_types) == 1 |
| 41 | + assert isinstance(cluster_type, ClusterType) |
| 42 | + assert cluster_type.id == CLUSTER_TYPE_ID |
| 43 | + assert cluster_type.model == 'H200' |
| 44 | + assert cluster_type.name == 'H200 Cluster' |
| 45 | + assert cluster_type.cluster_type == '16H200' |
| 46 | + assert cluster_type.price_per_hour == 45.5 |
| 47 | + assert cluster_type.currency == 'usd' |
| 48 | + assert cluster_type.manufacturer == 'NVIDIA' |
| 49 | + assert cluster_type.node_details == ['2x 8 GPU nodes'] |
| 50 | + assert cluster_type.supported_os == ['ubuntu-24.04-cuda-12.8-cluster'] |
| 51 | + assert responses.assert_call_count(endpoint, 1) is True |
0 commit comments