-
Notifications
You must be signed in to change notification settings - Fork 83
Integration tests for private image sharing #632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
36867af
b2bf5d9
744761b
c19136b
c5aadb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,252 @@ | ||||||
| import datetime | ||||||
| from test.integration.conftest import get_region | ||||||
| from test.integration.helpers import ( | ||||||
| get_test_label, | ||||||
| ) | ||||||
|
|
||||||
| import pytest | ||||||
|
|
||||||
| from linode_api4.objects import ( | ||||||
| Image, | ||||||
| ImageShareGroup, | ||||||
| ImageShareGroupImagesToAdd, | ||||||
| ImageShareGroupImageToAdd, | ||||||
| ImageShareGroupImageToUpdate, | ||||||
| ImageShareGroupMemberToAdd, | ||||||
| ImageShareGroupMemberToUpdate, | ||||||
| ImageShareGroupToken, | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
| def wait_for_image_status( | ||||||
| test_linode_client, image_id, expected_status, timeout=180, interval=5 | ||||||
| ): | ||||||
| import time | ||||||
|
|
||||||
| get_image = test_linode_client.load(Image, image_id) | ||||||
| timer = 0 | ||||||
| while get_image.status != expected_status and timer < timeout: | ||||||
| time.sleep(interval) | ||||||
| timer += interval | ||||||
| get_image = test_linode_client.load(Image, image_id) | ||||||
| if timer >= timeout: | ||||||
| raise TimeoutError( | ||||||
| f"Created image did not reach status '{expected_status}' within {timeout} seconds." | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
| @pytest.fixture(scope="class") | ||||||
| def sample_linode(test_linode_client, e2e_test_firewall): | ||||||
| client = test_linode_client | ||||||
| region = get_region(client, {"Linodes", "Cloud Firewall"}, site_type="core") | ||||||
| label = get_test_label(length=8) | ||||||
|
|
||||||
| linode_instance, password = client.linode.instance_create( | ||||||
| "g6-nanode-1", | ||||||
| region, | ||||||
| image="linode/debian12", | ||||||
| label=label + "_modlinode", | ||||||
| ) | ||||||
| yield linode_instance | ||||||
| linode_instance.delete() | ||||||
|
|
||||||
|
|
||||||
| @pytest.fixture(scope="class") | ||||||
| def create_image_id(test_linode_client, sample_linode): | ||||||
| create_image = test_linode_client.images.create( | ||||||
| sample_linode.disks[0], | ||||||
| label="linode-api4python-test-image-sharing-image", | ||||||
| ) | ||||||
| wait_for_image_status(test_linode_client, create_image.id, "available") | ||||||
| yield create_image.id | ||||||
| create_image.delete() | ||||||
|
|
||||||
|
|
||||||
| @pytest.fixture(scope="function") | ||||||
| def share_group_id(test_linode_client): | ||||||
| group_label = get_test_label(8) + "_sharegroup_api4_test" | ||||||
| group = test_linode_client.sharegroups.create_sharegroup( | ||||||
| label=group_label, | ||||||
| description="Test api4python", | ||||||
| ) | ||||||
| yield group.id | ||||||
| group.delete() | ||||||
|
|
||||||
|
|
||||||
| def test_get_share_groups(test_linode_client): | ||||||
|
||||||
| response = test_linode_client.sharegroups() | ||||||
| sharegroups_list = response.lists[0] | ||||||
| assert len(sharegroups_list) > 0 | ||||||
| assert sharegroups_list[0].api_endpoint == "/images/sharegroups/{id}" | ||||||
| assert sharegroups_list[0].id > 0 | ||||||
| assert sharegroups_list[0].description != "" | ||||||
| assert isinstance(sharegroups_list[0].images_count, int) | ||||||
| assert sharegroups_list[0].is_suspended == False | ||||||
|
||||||
| assert sharegroups_list[0].is_suspended == False | |
| assert not sharegroups_list[0].is_suspended |
Outdated
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 'is False' or 'assert not share_group.is_suspended' instead of '== False' for boolean comparisons to follow Python best practices.
Outdated
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The token value 'notExistingToken' uses camelCase which is inconsistent with Python naming conventions. Consider using 'not_existing_token' or 'invalid_token' instead.
Outdated
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The token value 'notExistingToken' uses camelCase which is inconsistent with Python naming conventions. Consider using 'not_existing_token' or 'invalid_token' for consistency.
Outdated
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The token value 'notExistingToken' uses camelCase which is inconsistent with Python naming conventions. Consider using 'not_existing_token' or 'invalid_token' for consistency.
Outdated
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The token value 'notExistingToken' uses camelCase which is inconsistent with Python naming conventions. Consider using 'not_existing_token' or 'invalid_token' for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step timed out for me locally. Can we increase the timeout?