Skip to content

Commit

Permalink
feat(server_type): add field for included traffic (#185)
Browse files Browse the repository at this point in the history
Field was recently added to the API: https://docs.hetzner.cloud/#server-types
  • Loading branch information
apricote authored May 11, 2023
1 parent 9d5afe0 commit 8ae0bc6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hcloud/server_types/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ class ServerType(BaseDomain, DomainIdentityMixin):
:param cpu_type: string
Type of cpu. Choices: `shared`, `dedicated`
:param architecture: string
Architecture of cpu. Choices: `x86`, `arm`
Architecture of cpu. Choices: `x86`, `arm`
:param deprecated: bool
True if server type is deprecated
:param included_traffic: int
Free traffic per month in bytes
"""

__slots__ = (
Expand All @@ -40,6 +42,7 @@ class ServerType(BaseDomain, DomainIdentityMixin):
"cpu_type",
"architecture",
"deprecated",
"included_traffic",
)

def __init__(
Expand All @@ -55,6 +58,7 @@ def __init__(
cpu_type=None,
architecture=None,
deprecated=None,
included_traffic=None,
):
self.id = id
self.name = name
Expand All @@ -67,3 +71,4 @@ def __init__(
self.cpu_type = cpu_type
self.architecture = architecture
self.deprecated = deprecated
self.included_traffic = included_traffic
4 changes: 4 additions & 0 deletions tests/unit/server_types/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def server_type_response():
"storage_type": "local",
"cpu_type": "shared",
"architecture": "x86",
"included_traffic": 21990232555520,
}
}

Expand Down Expand Up @@ -58,6 +59,7 @@ def two_server_types_response():
"storage_type": "local",
"cpu_type": "shared",
"architecture": "x86",
"included_traffic": 21990232555520,
},
{
"id": 2,
Expand Down Expand Up @@ -93,6 +95,7 @@ def two_server_types_response():
"storage_type": "local",
"cpu_type": "shared",
"architecture": "x86",
"included_traffic": 21990232555520,
},
]
}
Expand Down Expand Up @@ -125,6 +128,7 @@ def one_server_types_response():
"storage_type": "local",
"cpu_type": "shared",
"architecture": "x86",
"included_traffic": 21990232555520,
}
]
}
1 change: 1 addition & 0 deletions tests/unit/server_types/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_bound_server_type_init(self, server_type_response):
assert bound_server_type.storage_type == "local"
assert bound_server_type.cpu_type == "shared"
assert bound_server_type.architecture == "x86"
assert bound_server_type.included_traffic == 21990232555520


class TestServerTypesClient(object):
Expand Down

0 comments on commit 8ae0bc6

Please sign in to comment.