|
| 1 | +import pytest |
| 2 | + |
1 | 3 | from linode_api4.objects.object_storage import (
|
2 | 4 | ObjectStorageQuota,
|
3 | 5 | ObjectStorageQuotaUsage,
|
4 | 6 | )
|
5 | 7 |
|
6 | 8 |
|
7 |
| -def test_list_obj_storage_quotas(test_linode_client): |
| 9 | +def test_list_and_get_obj_storage_quotas(test_linode_client): |
8 | 10 | quotas = test_linode_client.object_storage.quotas()
|
9 | 11 |
|
10 |
| - target_quota_id = "obj-buckets-us-sea-1.linodeobjects.com" |
11 |
| - |
12 |
| - found_quota = None |
13 |
| - for quota in quotas: |
14 |
| - if quota.quota_id == target_quota_id: |
15 |
| - found_quota = quota |
16 |
| - break |
17 |
| - |
18 |
| - assert ( |
19 |
| - found_quota is not None |
20 |
| - ), f"Quota with ID {target_quota_id} not found." |
21 |
| - |
22 |
| - assert found_quota.quota_id == "obj-buckets-us-sea-1.linodeobjects.com" |
23 |
| - assert found_quota.quota_name == "max_buckets" |
24 |
| - assert found_quota.endpoint_type == "E1" |
25 |
| - assert found_quota.s3_endpoint == "us-sea-1.linodeobjects.com" |
26 |
| - assert ( |
27 |
| - found_quota.description |
28 |
| - == "Maximum number of buckets this customer is allowed to have on this endpoint" |
29 |
| - ) |
30 |
| - assert found_quota.quota_limit == 1000 |
31 |
| - assert found_quota.resource_metric == "bucket" |
| 12 | + if len(quotas) < 1: |
| 13 | + pytest.skip("No available quota for testing. Skipping now...") |
32 | 14 |
|
| 15 | + found_quota = quotas[0] |
33 | 16 |
|
34 |
| -def test_get_obj_storage_quota(test_linode_client): |
35 |
| - quota_id = "obj-objects-us-ord-1.linodeobjects.com" |
36 |
| - quota = test_linode_client.load(ObjectStorageQuota, quota_id) |
37 |
| - |
38 |
| - assert quota.quota_id == "obj-objects-us-ord-1.linodeobjects.com" |
39 |
| - assert quota.quota_name == "max_objects" |
40 |
| - assert quota.endpoint_type == "E1" |
41 |
| - assert quota.s3_endpoint == "us-ord-1.linodeobjects.com" |
42 |
| - assert ( |
43 |
| - quota.description |
44 |
| - == "Maximum number of objects this customer is allowed to have on this endpoint" |
| 17 | + get_quota = test_linode_client.load( |
| 18 | + ObjectStorageQuota, found_quota.quota_id |
45 | 19 | )
|
46 |
| - assert quota.quota_limit == 100000000 |
47 |
| - assert quota.resource_metric == "object" |
| 20 | + |
| 21 | + assert found_quota.quota_id == get_quota.quota_id |
| 22 | + assert found_quota.quota_name == get_quota.quota_name |
| 23 | + assert found_quota.endpoint_type == get_quota.endpoint_type |
| 24 | + assert found_quota.s3_endpoint == get_quota.s3_endpoint |
| 25 | + assert found_quota.description == get_quota.description |
| 26 | + assert found_quota.quota_limit == get_quota.quota_limit |
| 27 | + assert found_quota.resource_metric == get_quota.resource_metric |
48 | 28 |
|
49 | 29 |
|
50 | 30 | def test_get_obj_storage_quota_usage(test_linode_client):
|
51 |
| - quota_id = "obj-objects-us-ord-1.linodeobjects.com" |
| 31 | + quotas = test_linode_client.object_storage.quotas() |
| 32 | + |
| 33 | + if len(quotas) < 1: |
| 34 | + pytest.skip("No available quota for testing. Skipping now...") |
| 35 | + |
| 36 | + quota_id = quotas[0].quota_id |
52 | 37 | quota = test_linode_client.load(ObjectStorageQuota, quota_id)
|
53 | 38 |
|
54 | 39 | quota_usage = quota.usage()
|
55 | 40 |
|
56 | 41 | assert isinstance(quota_usage, ObjectStorageQuotaUsage)
|
57 |
| - assert quota_usage.quota_limit == 100000000 |
58 |
| - assert quota_usage.usage >= 0 |
| 42 | + assert quota_usage.quota_limit >= 0 |
| 43 | + |
| 44 | + if quota_usage.usage is not None: |
| 45 | + assert quota_usage.usage >= 0 |
0 commit comments