diff --git a/hcloud/certificates/domain.py b/hcloud/certificates/domain.py index 2434a745..6b231ed1 100644 --- a/hcloud/certificates/domain.py +++ b/hcloud/certificates/domain.py @@ -87,6 +87,13 @@ class ManagedCertificateStatus(BaseDomain): If issuance or renewal reports failure, this property contains information about what happened """ + __api_properties__ = ( + "issuance", + "renewal", + "error", + ) + __slots__ = __api_properties__ + def __init__( self, issuance: str | None = None, @@ -107,6 +114,12 @@ class ManagedCertificateError(BaseDomain): Message detailing the error """ + __api_properties__ = ( + "code", + "message", + ) + __slots__ = __api_properties__ + def __init__(self, code: str | None = None, message: str | None = None): self.code = code self.message = message diff --git a/hcloud/load_balancers/domain.py b/hcloud/load_balancers/domain.py index fb047a19..6a24547f 100644 --- a/hcloud/load_balancers/domain.py +++ b/hcloud/load_balancers/domain.py @@ -229,6 +229,15 @@ class LoadBalancerServiceHttp(BaseDomain): Use sticky sessions. Only available if protocol is "http" or "https". """ + __api_properties__ = ( + "cookie_name", + "cookie_lifetime", + "certificates", + "redirect_http", + "sticky_sessions", + ) + __slots__ = __api_properties__ + def __init__( self, cookie_name: str | None = None, @@ -261,6 +270,16 @@ class LoadBalancerHealthCheck(BaseDomain): HTTP Config """ + __api_properties__ = ( + "protocol", + "port", + "interval", + "timeout", + "retries", + "http", + ) + __slots__ = __api_properties__ + def __init__( self, protocol: str | None = None, @@ -293,6 +312,15 @@ class LoadBalancerHealthCheckHttp(BaseDomain): Type of health check """ + __api_properties__ = ( + "domain", + "path", + "response", + "status_codes", + "tls", + ) + __slots__ = __api_properties__ + def __init__( self, domain: str | None = None, @@ -350,6 +378,16 @@ class LoadBalancerTarget(BaseDomain): List of health statuses of the services on this target. Only present for target types "server" and "ip". """ + __api_properties__ = ( + "type", + "server", + "label_selector", + "ip", + "use_private_ip", + "health_status", + ) + __slots__ = __api_properties__ + def __init__( self, type: str | None = None, @@ -401,6 +439,12 @@ class LoadBalancerTargetHealthStatus(BaseDomain): :param status: Load Balancer Target status. Choices: healthy, unhealthy, unknown """ + __api_properties__ = ( + "listen_port", + "status", + ) + __slots__ = __api_properties__ + def __init__( self, listen_port: int | None = None, @@ -416,6 +460,9 @@ class LoadBalancerTargetLabelSelector(BaseDomain): :param selector: str Target label selector """ + __api_properties__ = ("selector",) + __slots__ = __api_properties__ + def __init__(self, selector: str | None = None): self.selector = selector @@ -426,6 +473,9 @@ class LoadBalancerTargetIP(BaseDomain): :param ip: str Target IP """ + __api_properties__ = ("ip",) + __slots__ = __api_properties__ + def __init__(self, ip: str | None = None): self.ip = ip @@ -437,6 +487,9 @@ class LoadBalancerAlgorithm(BaseDomain): Algorithm of the Load Balancer. Choices: round_robin, least_connections """ + __api_properties__ = ("type",) + __slots__ = __api_properties__ + def __init__(self, type: str | None = None): self.type = type diff --git a/tests/unit/actions/test_domain.py b/tests/unit/actions/test_domain.py index 5133a240..c5efcde5 100644 --- a/tests/unit/actions/test_domain.py +++ b/tests/unit/actions/test_domain.py @@ -13,6 +13,16 @@ ) +@pytest.mark.parametrize( + "value", + [ + (Action(id=1),), + ], +) +def test_eq(value): + assert value == value + + class TestAction: def test_started_finished_is_datetime(self): action = Action( diff --git a/tests/unit/certificates/test_domain.py b/tests/unit/certificates/test_domain.py index df916964..d65a61ee 100644 --- a/tests/unit/certificates/test_domain.py +++ b/tests/unit/certificates/test_domain.py @@ -3,7 +3,25 @@ import datetime from datetime import timezone -from hcloud.certificates import Certificate +import pytest + +from hcloud.certificates import ( + Certificate, + ManagedCertificateError, + ManagedCertificateStatus, +) + + +@pytest.mark.parametrize( + "value", + [ + (Certificate(id=1),), + (ManagedCertificateError()), + (ManagedCertificateStatus()), + ], +) +def test_eq(value): + assert value == value class TestCertificate: diff --git a/tests/unit/datacenters/test_domain.py b/tests/unit/datacenters/test_domain.py new file mode 100644 index 00000000..09ed99ed --- /dev/null +++ b/tests/unit/datacenters/test_domain.py @@ -0,0 +1,16 @@ +from __future__ import annotations + +import pytest + +from hcloud.datacenters import Datacenter, DatacenterServerTypes + + +@pytest.mark.parametrize( + "value", + [ + (Datacenter(id=1),), + (DatacenterServerTypes(available=[], available_for_migration=[], supported=[])), + ], +) +def test_eq(value): + assert value == value diff --git a/tests/unit/deprecation/__init__.py b/tests/unit/deprecation/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/deprecation/test_domain.py b/tests/unit/deprecation/test_domain.py new file mode 100644 index 00000000..35c8473f --- /dev/null +++ b/tests/unit/deprecation/test_domain.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +import pytest + +from hcloud.deprecation import DeprecationInfo + + +@pytest.mark.parametrize( + "value", + [ + (DeprecationInfo(),), + ], +) +def test_eq(value): + assert value == value diff --git a/tests/unit/firewalls/test_domain.py b/tests/unit/firewalls/test_domain.py index 6c641222..ec303c14 100644 --- a/tests/unit/firewalls/test_domain.py +++ b/tests/unit/firewalls/test_domain.py @@ -3,7 +3,29 @@ import datetime from datetime import timezone -from hcloud.firewalls import Firewall +import pytest + +from hcloud.firewalls import ( + Firewall, + FirewallResource, + FirewallResourceAppliedToResources, + FirewallResourceLabelSelector, + FirewallRule, +) + + +@pytest.mark.parametrize( + "value", + [ + (Firewall(id=1),), + (FirewallRule(direction="in", protocol="icmp", source_ips=[]),), + (FirewallResource(type="server"),), + (FirewallResourceAppliedToResources(type="server"),), + (FirewallResourceLabelSelector(),), + ], +) +def test_eq(value): + assert value == value class TestFirewall: diff --git a/tests/unit/floating_ips/test_domain.py b/tests/unit/floating_ips/test_domain.py index 69e50161..a16a25b4 100644 --- a/tests/unit/floating_ips/test_domain.py +++ b/tests/unit/floating_ips/test_domain.py @@ -3,9 +3,21 @@ import datetime from datetime import timezone +import pytest + from hcloud.floating_ips import FloatingIP +@pytest.mark.parametrize( + "value", + [ + (FloatingIP(id=1),), + ], +) +def test_eq(value): + assert value == value + + class TestFloatingIP: def test_created_is_datetime(self): floatingIP = FloatingIP(id=1, created="2016-01-30T23:50+00:00") diff --git a/tests/unit/images/test_domain.py b/tests/unit/images/test_domain.py index 5c768877..d85c8a18 100644 --- a/tests/unit/images/test_domain.py +++ b/tests/unit/images/test_domain.py @@ -3,9 +3,21 @@ import datetime from datetime import timezone +import pytest + from hcloud.images import Image +@pytest.mark.parametrize( + "value", + [ + (Image(id=1),), + ], +) +def test_eq(value): + assert value == value + + class TestImage: def test_created_is_datetime(self): image = Image(id=1, created="2016-01-30T23:50+00:00") diff --git a/tests/unit/isos/test_domain.py b/tests/unit/isos/test_domain.py index 5017b529..c056f3b7 100644 --- a/tests/unit/isos/test_domain.py +++ b/tests/unit/isos/test_domain.py @@ -7,6 +7,16 @@ from hcloud.isos import Iso +@pytest.mark.parametrize( + "value", + [ + (Iso(id=1),), + ], +) +def test_eq(value): + assert value == value + + class TestIso: @pytest.fixture() def deprecated_iso(self): diff --git a/tests/unit/load_balancer_types/test_domain.py b/tests/unit/load_balancer_types/test_domain.py new file mode 100644 index 00000000..d3b8eff7 --- /dev/null +++ b/tests/unit/load_balancer_types/test_domain.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +import pytest + +from hcloud.load_balancer_types import LoadBalancerType + + +@pytest.mark.parametrize( + "value", + [ + (LoadBalancerType(id=1),), + ], +) +def test_eq(value): + assert value == value diff --git a/tests/unit/load_balancers/test_domain.py b/tests/unit/load_balancers/test_domain.py index 24bed108..37d1b981 100644 --- a/tests/unit/load_balancers/test_domain.py +++ b/tests/unit/load_balancers/test_domain.py @@ -3,7 +3,53 @@ import datetime from datetime import timezone -from hcloud.load_balancers import LoadBalancer +import pytest + +from hcloud.load_balancers import ( + IPv4Address, + IPv6Network, + LoadBalancer, + LoadBalancerAlgorithm, + LoadBalancerHealthCheck, + LoadBalancerHealthCheckHttp, + LoadBalancerService, + LoadBalancerServiceHttp, + LoadBalancerTarget, + LoadBalancerTargetHealthStatus, + LoadBalancerTargetIP, + LoadBalancerTargetLabelSelector, + PrivateNet, + PublicNetwork, +) + + +@pytest.mark.parametrize( + "value", + [ + (LoadBalancer(id=1),), + (LoadBalancerService,), + (LoadBalancerServiceHttp(),), + (LoadBalancerHealthCheck(),), + (LoadBalancerHealthCheckHttp(),), + (LoadBalancerTarget(),), + (LoadBalancerTargetHealthStatus(),), + (LoadBalancerTargetLabelSelector(),), + (LoadBalancerTargetIP(),), + (LoadBalancerAlgorithm(),), + ( + PublicNetwork( + ipv4=IPv4Address(ip="127.0.0.1", dns_ptr="example.com"), + ipv6=IPv6Network("2001:0db8::0/64", dns_ptr="example.com"), + enabled=True, + ), + ), + (IPv4Address(ip="127.0.0.1", dns_ptr="example.com"),), + (IPv6Network("2001:0db8::0/64", dns_ptr="example.com"),), + (PrivateNet(network=object(), ip="127.0.0.1"),), + ], +) +def test_eq(value): + assert value == value class TestLoadBalancers: diff --git a/tests/unit/locations/test_domain.py b/tests/unit/locations/test_domain.py new file mode 100644 index 00000000..fd5d710a --- /dev/null +++ b/tests/unit/locations/test_domain.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +import pytest + +from hcloud.locations import Location + + +@pytest.mark.parametrize( + "value", + [ + (Location(id=1),), + ], +) +def test_eq(value): + assert value == value diff --git a/tests/unit/networks/test_domain.py b/tests/unit/networks/test_domain.py index 1e5f10e3..187de5fb 100644 --- a/tests/unit/networks/test_domain.py +++ b/tests/unit/networks/test_domain.py @@ -3,7 +3,21 @@ import datetime from datetime import timezone -from hcloud.networks import Network +import pytest + +from hcloud.networks import Network, NetworkRoute, NetworkSubnet + + +@pytest.mark.parametrize( + "value", + [ + (Network(id=1),), + (NetworkSubnet(ip_range="10.0.1.0/24"),), + (NetworkRoute(destination="10.0.1.2", gateway="10.0.1.1"),), + ], +) +def test_eq(value): + assert value == value class TestNetwork: diff --git a/tests/unit/placement_groups/test_domain.py b/tests/unit/placement_groups/test_domain.py index 91fd0c3d..f8293fcc 100644 --- a/tests/unit/placement_groups/test_domain.py +++ b/tests/unit/placement_groups/test_domain.py @@ -3,9 +3,21 @@ import datetime from datetime import timezone +import pytest + from hcloud.placement_groups import PlacementGroup +@pytest.mark.parametrize( + "value", + [ + (PlacementGroup(id=1),), + ], +) +def test_eq(value): + assert value == value + + class TestPlacementGroup: def test_created_is_datetime(self): placement_group = PlacementGroup(id=1, created="2016-01-30T23:50+00:00") diff --git a/tests/unit/primary_ips/test_domain.py b/tests/unit/primary_ips/test_domain.py index 945522fd..5adcf226 100644 --- a/tests/unit/primary_ips/test_domain.py +++ b/tests/unit/primary_ips/test_domain.py @@ -3,9 +3,21 @@ import datetime from datetime import timezone +import pytest + from hcloud.primary_ips import PrimaryIP +@pytest.mark.parametrize( + "value", + [ + (PrimaryIP(id=1),), + ], +) +def test_eq(value): + assert value == value + + class TestPrimaryIP: def test_created_is_datetime(self): primaryIP = PrimaryIP(id=1, created="2016-01-30T23:50+00:00") diff --git a/tests/unit/server_types/test_domain.py b/tests/unit/server_types/test_domain.py new file mode 100644 index 00000000..4d7a28c2 --- /dev/null +++ b/tests/unit/server_types/test_domain.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +import pytest + +from hcloud.server_types import ServerType + + +@pytest.mark.parametrize( + "value", + [ + (ServerType(id=1),), + ], +) +def test_eq(value): + assert value == value diff --git a/tests/unit/servers/test_domain.py b/tests/unit/servers/test_domain.py index a4d10b63..fdc05335 100644 --- a/tests/unit/servers/test_domain.py +++ b/tests/unit/servers/test_domain.py @@ -3,7 +3,41 @@ import datetime from datetime import timezone -from hcloud.servers import Server +import pytest + +from hcloud.servers import ( + IPv4Address, + IPv6Network, + PrivateNet, + PublicNetwork, + PublicNetworkFirewall, + Server, + ServerCreatePublicNetwork, +) + + +@pytest.mark.parametrize( + "value", + [ + (Server(id=1),), + ( + PublicNetwork( + ipv4=None, + ipv6=None, + floating_ips=[], + primary_ipv4=None, + primary_ipv6=None, + ), + ), + (PublicNetworkFirewall(firewall=object(), status="pending"),), + (IPv4Address(ip="127.0.0.1", blocked=False, dns_ptr="example.com"),), + (IPv6Network("2001:0db8::0/64", blocked=False, dns_ptr="example.com"),), + (PrivateNet(network=object(), ip="127.0.0.1", alias_ips=[], mac_address=""),), + (ServerCreatePublicNetwork(),), + ], +) +def test_eq(value): + assert value == value class TestServer: diff --git a/tests/unit/ssh_keys/test_domain.py b/tests/unit/ssh_keys/test_domain.py index edcf7526..e354128e 100644 --- a/tests/unit/ssh_keys/test_domain.py +++ b/tests/unit/ssh_keys/test_domain.py @@ -3,9 +3,21 @@ import datetime from datetime import timezone +import pytest + from hcloud.ssh_keys import SSHKey +@pytest.mark.parametrize( + "value", + [ + (SSHKey(id=1),), + ], +) +def test_eq(value): + assert value == value + + class TestSSHKey: def test_created_is_datetime(self): sshKey = SSHKey(id=1, created="2016-01-30T23:50+00:00") diff --git a/tests/unit/volumes/test_domain.py b/tests/unit/volumes/test_domain.py index 3844f2de..f69329d9 100644 --- a/tests/unit/volumes/test_domain.py +++ b/tests/unit/volumes/test_domain.py @@ -3,9 +3,21 @@ import datetime from datetime import timezone +import pytest + from hcloud.volumes import Volume +@pytest.mark.parametrize( + "value", + [ + (Volume(id=1),), + ], +) +def test_eq(value): + assert value == value + + class TestVolume: def test_created_is_datetime(self): volume = Volume(id=1, created="2016-01-30T23:50+00:00")