Skip to content

Commit db6dc0b

Browse files
committed
test: equality for all domain classes
1 parent 47134e1 commit db6dc0b

File tree

5 files changed

+105
-1
lines changed

5 files changed

+105
-1
lines changed

hcloud/certificates/domain.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ class ManagedCertificateStatus(BaseDomain):
8787
If issuance or renewal reports failure, this property contains information about what happened
8888
"""
8989

90+
__api_properties__ = (
91+
"issuance",
92+
"renewal",
93+
"error",
94+
)
95+
__slots__ = __api_properties__
96+
9097
def __init__(
9198
self,
9299
issuance: str | None = None,

hcloud/load_balancers/domain.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,15 @@ class LoadBalancerServiceHttp(BaseDomain):
228228
Use sticky sessions. Only available if protocol is "http" or "https".
229229
"""
230230

231+
__api_properties__ = (
232+
"cookie_name",
233+
"cookie_lifetime",
234+
"certificates",
235+
"redirect_http",
236+
"sticky_sessions",
237+
)
238+
__slots__ = __api_properties__
239+
231240
def __init__(
232241
self,
233242
cookie_name: str | None = None,
@@ -260,6 +269,16 @@ class LoadBalancerHealthCheck(BaseDomain):
260269
HTTP Config
261270
"""
262271

272+
__api_properties__ = (
273+
"protocol",
274+
"port",
275+
"interval",
276+
"timeout",
277+
"retries",
278+
"http",
279+
)
280+
__slots__ = __api_properties__
281+
263282
def __init__(
264283
self,
265284
protocol: str | None = None,
@@ -292,6 +311,15 @@ class LoadBalancerHealtCheckHttp(BaseDomain):
292311
Type of health check
293312
"""
294313

314+
__api_properties__ = (
315+
"domain",
316+
"path",
317+
"response",
318+
"status_codes",
319+
"tls",
320+
)
321+
__slots__ = __api_properties__
322+
295323
def __init__(
296324
self,
297325
domain: str | None = None,
@@ -324,6 +352,16 @@ class LoadBalancerTarget(BaseDomain):
324352
List of health statuses of the services on this target. Only present for target types "server" and "ip".
325353
"""
326354

355+
__api_properties__ = (
356+
"type",
357+
"server",
358+
"label_selector",
359+
"ip",
360+
"use_private_ip",
361+
"health_status",
362+
)
363+
__slots__ = __api_properties__
364+
327365
def __init__(
328366
self,
329367
type: str | None = None,
@@ -375,6 +413,12 @@ class LoadBalancerTargetHealthStatus(BaseDomain):
375413
:param status: Load Balancer Target status. Choices: healthy, unhealthy, unknown
376414
"""
377415

416+
__api_properties__ = (
417+
"listen_port",
418+
"status",
419+
)
420+
__slots__ = __api_properties__
421+
378422
def __init__(
379423
self,
380424
listen_port: int | None = None,
@@ -390,6 +434,9 @@ class LoadBalancerTargetLabelSelector(BaseDomain):
390434
:param selector: str Target label selector
391435
"""
392436

437+
__api_properties__ = ("selector",)
438+
__slots__ = __api_properties__
439+
393440
def __init__(self, selector: str | None = None):
394441
self.selector = selector
395442

@@ -400,6 +447,9 @@ class LoadBalancerTargetIP(BaseDomain):
400447
:param ip: str Target IP
401448
"""
402449

450+
__api_properties__ = ("ip",)
451+
__slots__ = __api_properties__
452+
403453
def __init__(self, ip: str | None = None):
404454
self.ip = ip
405455

@@ -411,6 +461,9 @@ class LoadBalancerAlgorithm(BaseDomain):
411461
Algorithm of the Load Balancer. Choices: round_robin, least_connections
412462
"""
413463

464+
__api_properties__ = ("type",)
465+
__slots__ = __api_properties__
466+
414467
def __init__(self, type: str | None = None):
415468
self.type = type
416469

tests/unit/actions/test_domain.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
)
1414

1515

16+
@pytest.mark.parametrize(
17+
"value",
18+
[
19+
(Action(id=1),),
20+
],
21+
)
22+
def test_eq(value):
23+
assert value == value
24+
25+
1626
class TestAction:
1727
def test_started_finished_is_datetime(self):
1828
action = Action(

tests/unit/certificates/test_domain.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,25 @@
33
import datetime
44
from datetime import timezone
55

6-
from hcloud.certificates import Certificate
6+
import pytest
7+
8+
from hcloud.certificates import (
9+
Certificate,
10+
ManagedCertificateError,
11+
ManagedCertificateStatus,
12+
)
13+
14+
15+
@pytest.mark.parametrize(
16+
"value",
17+
[
18+
(Certificate(id=1),),
19+
(ManagedCertificateError()),
20+
(ManagedCertificateStatus()),
21+
],
22+
)
23+
def test_eq(value):
24+
assert value == value
725

826

927
class TestCertificate:
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from __future__ import annotations
2+
3+
import pytest
4+
5+
from hcloud.datacenters import Datacenter, DatacenterServerTypes
6+
7+
8+
@pytest.mark.parametrize(
9+
"value",
10+
[
11+
(Datacenter(id=1),),
12+
(DatacenterServerTypes(available=[], available_for_migration=[], supported=[])),
13+
],
14+
)
15+
def test_eq(value):
16+
assert value == value

0 commit comments

Comments
 (0)