Skip to content

Commit ba062c4

Browse files
authored
add obj quotas int tests (#535)
1 parent 5342d35 commit ba062c4

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from linode_api4.objects.object_storage import (
2+
ObjectStorageQuota,
3+
ObjectStorageQuotaUsage,
4+
)
5+
6+
7+
def test_list_obj_storage_quotas(test_linode_client):
8+
quotas = test_linode_client.object_storage.quotas()
9+
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"
32+
33+
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"
45+
)
46+
assert quota.quota_limit == 100000000
47+
assert quota.resource_metric == "object"
48+
49+
50+
def test_get_obj_storage_quota_usage(test_linode_client):
51+
quota_id = "obj-objects-us-ord-1.linodeobjects.com"
52+
quota = test_linode_client.load(ObjectStorageQuota, quota_id)
53+
54+
quota_usage = quota.usage()
55+
56+
assert isinstance(quota_usage, ObjectStorageQuotaUsage)
57+
assert quota_usage.quota_limit == 100000000
58+
assert quota_usage.usage >= 0

0 commit comments

Comments
 (0)