-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fill in test gaps in models and improve fixtures
- Loading branch information
1 parent
d4e8f9f
commit 24f4fc3
Showing
8 changed files
with
203 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
test/integration/models/objectstorage/test_obj_storage.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import time | ||
from test.integration.conftest import get_region | ||
|
||
import pytest | ||
|
||
from linode_api4.objects import ( | ||
ObjectStorageACL, | ||
ObjectStorageBucket, | ||
ObjectStorageCluster, | ||
ObjectStorageKeys, | ||
) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def test_object_storage_bucket(test_linode_client): | ||
client = test_linode_client | ||
|
||
region = get_region(client, {"Object Storage"}) | ||
cluster_region_name = region.id + "-1" | ||
label = str(time.time_ns())[:-5] + "-bucket" | ||
|
||
bucket = client.object_storage.bucket_create( | ||
cluster=cluster_region_name, label=label | ||
) | ||
|
||
yield bucket | ||
|
||
bucket.delete() | ||
|
||
|
||
def test_list_obj_storage_bucket( | ||
test_linode_client, test_object_storage_bucket | ||
): | ||
client = test_linode_client | ||
|
||
buckets = client.object_storage.buckets() | ||
target_bucket = test_object_storage_bucket | ||
|
||
bucket_ids = [bucket.id for bucket in buckets] | ||
|
||
assert target_bucket.id in bucket_ids | ||
assert isinstance(target_bucket, ObjectStorageBucket) | ||
|
||
|
||
def test_bucket_access_modify(test_object_storage_bucket): | ||
bucket = test_object_storage_bucket | ||
|
||
res = bucket.access_modify(ObjectStorageACL.PRIVATE, cors_enabled=True) | ||
|
||
assert res | ||
|
||
|
||
def test_bucket_access_update(test_object_storage_bucket): | ||
bucket = test_object_storage_bucket | ||
res = bucket.access_update(ObjectStorageACL.PRIVATE, cors_enabled=True) | ||
|
||
assert res | ||
|
||
|
||
def test_get_ssl_cert(test_object_storage_bucket): | ||
bucket = test_object_storage_bucket | ||
|
||
res = bucket.ssl_cert().ssl | ||
|
||
assert res is False | ||
|
||
|
||
def test_create_key_for_specific_bucket( | ||
test_linode_client, test_object_storage_bucket | ||
): | ||
client = test_linode_client | ||
bucket = test_object_storage_bucket | ||
keys = client.object_storage.keys_create( | ||
"restricted-keys", | ||
bucket_access=client.object_storage.bucket_access( | ||
bucket.cluster, bucket.id, "read_write" | ||
), | ||
) | ||
|
||
assert isinstance(keys, ObjectStorageKeys) | ||
assert keys.bucket_access[0].bucket_name == bucket.id | ||
assert keys.bucket_access[0].permissions == "read_write" | ||
assert keys.bucket_access[0].cluster == bucket.cluster | ||
|
||
|
||
def test_get_cluster(test_linode_client, test_object_storage_bucket): | ||
client = test_linode_client | ||
bucket = test_object_storage_bucket | ||
|
||
cluster = client.load(ObjectStorageCluster, bucket.cluster) | ||
|
||
assert "linodeobjects.com" in cluster.domain | ||
assert cluster.id == bucket.cluster | ||
assert "available" == cluster.status | ||
|
||
|
||
def test_get_buckets_in_cluster(test_linode_client, test_object_storage_bucket): | ||
client = test_linode_client | ||
bucket = test_object_storage_bucket | ||
|
||
cluster = client.load(ObjectStorageCluster, bucket.cluster) | ||
buckets = cluster.buckets_in_cluster() | ||
bucket_ids = [bucket.id for bucket in buckets] | ||
|
||
assert bucket.id in bucket_ids |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from linode_api4.objects import PersonalAccessToken, Profile, SSHKey | ||
|
||
|
||
def test_user_profile(test_linode_client): | ||
client = test_linode_client | ||
|
||
profile = client.profile() | ||
|
||
assert isinstance(profile, Profile) | ||
|
||
|
||
def test_get_personal_access_token_objects(test_linode_client): | ||
client = test_linode_client | ||
|
||
personal_access_tokens = client.profile.tokens() | ||
|
||
if len(personal_access_tokens) > 0: | ||
assert isinstance(personal_access_tokens[0], PersonalAccessToken) | ||
|
||
|
||
def test_get_sshkeys(test_linode_client, test_sshkey): | ||
client = test_linode_client | ||
|
||
ssh_keys = client.profile.ssh_keys() | ||
|
||
ssh_labels = [i.label for i in ssh_keys] | ||
|
||
assert isinstance(test_sshkey, SSHKey) | ||
assert test_sshkey.label in ssh_labels | ||
|
||
|
||
def test_ssh_key_create(test_sshkey, ssh_key_gen): | ||
pub_key = ssh_key_gen[0] | ||
key = test_sshkey | ||
|
||
assert pub_key == key._raw_json["ssh_key"] |