Skip to content

Commit

Permalink
Add more detailed assertions for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ykim-akamai committed Sep 11, 2024
1 parent 10b9979 commit 0e4b319
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 7 deletions.
23 changes: 21 additions & 2 deletions test/integration/models/lke/test_lke.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
LKEClusterControlPlaneACLOptions,
LKEClusterControlPlaneOptions,
)
from linode_api4.common import RegionPrice
from linode_api4.errors import ApiError
from linode_api4.objects import LKECluster, LKENodePool, LKENodePoolTaint
from linode_api4.objects import (
LKECluster,
LKENodePool,
LKENodePoolTaint,
LKEType,
)


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -325,4 +331,17 @@ def test_lke_cluster_labels_and_taints(lke_cluster_with_labels_and_taints):
def test_lke_types(test_linode_client):
types = test_linode_client.lke.types()

assert len(types) > 0
if len(types) > 0:
for lke_type in types:
assert type(lke_type) is LKEType
assert lke_type.price.monthly is None or (
isinstance(lke_type.price.monthly, (float, int))
and lke_type.price.monthly >= 0
)
if len(lke_type.region_prices) > 0:
region_price = lke_type.region_prices[0]
assert type(region_price) is RegionPrice
assert lke_type.price.monthly is None or (
isinstance(lke_type.price.monthly, (float, int))
and lke_type.price.monthly >= 0
)
9 changes: 8 additions & 1 deletion test/integration/models/networking/test_networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from linode_api4.objects import Config, ConfigInterfaceIPv4, Firewall, IPAddress
from linode_api4.objects.networking import NetworkTransferPrice, Price


@pytest.mark.smoke
Expand Down Expand Up @@ -126,4 +127,10 @@ def test_ip_info_vpc(test_linode_client, create_vpc_with_subnet_and_linode):
def test_network_transfer_prices(test_linode_client):
transfer_prices = test_linode_client.networking.transfer_prices()

assert len(transfer_prices) > 0
if len(transfer_prices) > 0:
assert type(transfer_prices[0]) is NetworkTransferPrice
assert type(transfer_prices[0].price) is Price
assert (
transfer_prices[0].price is None
or transfer_prices[0].price.hourly >= 0
)
22 changes: 20 additions & 2 deletions test/integration/models/nodebalancer/test_nodebalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import pytest

from linode_api4 import ApiError
from linode_api4.objects import NodeBalancerConfig, NodeBalancerNode
from linode_api4.objects import (
NodeBalancerConfig,
NodeBalancerNode,
NodeBalancerType,
RegionPrice,
)


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -126,4 +131,17 @@ def test_delete_nb_node(test_linode_client, create_nb_config):
def test_nodebalancer_types(test_linode_client):
types = test_linode_client.nodebalancers.types()

assert len(types) > 0
if len(types) > 0:
for nb_type in types:
assert type(nb_type) is NodeBalancerType
assert nb_type.price.monthly is None or (
isinstance(nb_type.price.monthly, (float, int))
and nb_type.price.monthly >= 0
)
if len(nb_type.region_prices) > 0:
region_price = nb_type.region_prices[0]
assert type(region_price) is RegionPrice
assert region_price.monthly is None or (
isinstance(region_price.monthly, (float, int))
and region_price.monthly >= 0
)
17 changes: 15 additions & 2 deletions test/integration/models/volume/test_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest

from linode_api4 import ApiError, LinodeClient
from linode_api4.objects import Volume
from linode_api4.objects import RegionPrice, Volume, VolumeType


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -126,4 +126,17 @@ def test_detach_volume_to_linode(
def test_volume_types(test_linode_client):
types = test_linode_client.volumes.types()

assert len(types) > 0
if len(types) > 0:
for volume_type in types:
assert type(volume_type) is VolumeType
assert volume_type.price.monthly is None or (
isinstance(volume_type.price.monthly, (float, int))
and volume_type.price.monthly >= 0
)
if len(volume_type.region_prices) > 0:
region_price = volume_type.region_prices[0]
assert type(region_price) is RegionPrice
assert region_price.monthly is None or (
isinstance(region_price.monthly, (float, int))
and region_price.monthly >= 0
)

0 comments on commit 0e4b319

Please sign in to comment.