Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions test/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
from linode_api4.objects import Capability, Region

ENV_TOKEN_NAME = "LINODE_TOKEN"
ENV_API_URL_NAME = "LINODE_API_URL"
ENV_API_URL_NAME = "LINODE_URL"
ENV_API_VERSION_NAME = "LINODE_API_VERSION"
ENV_REGION_OVERRIDE = "LINODE_TEST_REGION_OVERRIDE"
ENV_API_CA_NAME = "LINODE_API_CA"
RUN_LONG_TESTS = "RUN_LONG_TESTS"
Expand All @@ -57,7 +58,9 @@ def get_token():


def get_api_url():
return os.environ.get(ENV_API_URL_NAME, "https://api.linode.com/v4beta")
api_url = os.environ.get(ENV_API_URL_NAME, "https://api.linode.com")
api_version = os.environ.get(ENV_API_VERSION_NAME, "v4beta")
return f"{api_url.rstrip('/')}/{api_version}"


def get_regions(
Expand Down
56 changes: 55 additions & 1 deletion test/integration/linode_client/test_linode_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
import time
from test.integration.conftest import get_region
from test.integration.conftest import get_api_url, get_region
from test.integration.helpers import get_test_label, wait_for_condition

import pytest
Expand All @@ -14,6 +14,60 @@
)


@pytest.mark.parametrize(
"environment, expected_url",
[
({}, "https://api.linode.com/v4beta"),
(
{"LINODE_URL": "https://api.example.test"},
"https://api.example.test/v4beta",
),
(
{"LINODE_URL": "https://api.example.test/"},
"https://api.example.test/v4beta",
),
(
{"LINODE_API_VERSION": "v4"},
"https://api.linode.com/v4",
),
(
{
"LINODE_URL": "https://api.example.test/",
"LINODE_API_VERSION": "v4",
},
"https://api.example.test/v4",
),
(
{
"LINODE_URL": "http://localhost:8080/proxy///",
"LINODE_API_VERSION": "v4beta",
},
"http://localhost:8080/proxy/v4beta",
),
(
{"LINODE_API_URL": "https://legacy.example.test/v4"},
"https://api.linode.com/v4beta",
),
(
{
"LINODE_API_URL": "https://legacy.example.test/v4",
"LINODE_URL": "https://api.example.test",
"LINODE_API_VERSION": "v4",
},
"https://api.example.test/v4",
),
],
)
def test_api_url_environment(monkeypatch, environment, expected_url):
for name in ("LINODE_URL", "LINODE_API_VERSION", "LINODE_API_URL"):
monkeypatch.delenv(name, raising=False)

for name, value in environment.items():
monkeypatch.setenv(name, value)

assert get_api_url() == expected_url


def is_tag_created(client, tag_label):
tags = client.tags()
tag_label_list = [i.label for i in tags]
Expand Down
Loading