Skip to content

Commit

Permalink
Merge pull request #332 from lgarber-akamai/new/dc-e2e
Browse files Browse the repository at this point in the history
new: Add integration test for `region_prices` Type field
  • Loading branch information
lgarber-akamai committed Sep 25, 2023
2 parents 02a4991 + 182dec6 commit a9915d4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@
from linode_api4.linode_client import LinodeClient

ENV_TOKEN_NAME = "LINODE_TOKEN"
ENV_API_URL_NAME = "LINODE_API_URL"
ENV_API_CA_NAME = "LINODE_API_CA"
RUN_LONG_TESTS = "RUN_LONG_TESTS"


def get_token():
return os.environ.get(ENV_TOKEN_NAME, None)


def get_api_url():
return os.environ.get(ENV_API_URL_NAME, "https://api.linode.com/v4beta")


def get_api_ca_file():
result = os.environ.get(ENV_API_CA_NAME, None)
return result if result != "" else None


def run_long_tests():
return os.environ.get(RUN_LONG_TESTS, None)

Expand Down Expand Up @@ -71,7 +82,13 @@ def ssh_key_gen():
@pytest.fixture(scope="session")
def get_client():
token = get_token()
client = LinodeClient(token)
api_url = get_api_url()
api_ca_file = get_api_ca_file()
client = LinodeClient(
token,
base_url=api_url,
ca_path=api_ca_file,
)
return client


Expand Down
16 changes: 16 additions & 0 deletions test/integration/models/test_linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,22 @@ def test_get_linode_types(get_client):
assert "g6-nanode-1" in ids


def test_get_linode_types_overrides(get_client):
types = get_client.linode.types()

target_types = [
v
for v in types
if len(v.region_prices) > 0 and v.region_prices[0].hourly > 0
]

assert len(target_types) > 0

for linode_type in target_types:
assert linode_type.region_prices[0].hourly >= 0
assert linode_type.region_prices[0].monthly >= 0


def test_get_linode_type_by_id(get_client):
pytest.skip(
"Might need Type to match how other object models are behaving e.g. client.load(Type, 123)"
Expand Down

0 comments on commit a9915d4

Please sign in to comment.