Skip to content
Snippets Groups Projects
Commit 6febb51f authored by Leo Antunes's avatar Leo Antunes
Browse files

New upstream version 1.19.0

parent 626d7739
No related branches found
No related tags found
No related merge requests found
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: hcloud Name: hcloud
Version: 1.18.2 Version: 1.19.0
Summary: Official Hetzner Cloud python library Summary: Official Hetzner Cloud python library
Home-page: https://github.com/hetznercloud/hcloud-python Home-page: https://github.com/hetznercloud/hcloud-python
Author: Hetzner Cloud GmbH Author: Hetzner Cloud GmbH
......
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: hcloud Name: hcloud
Version: 1.18.2 Version: 1.19.0
Summary: Official Hetzner Cloud python library Summary: Official Hetzner Cloud python library
Home-page: https://github.com/hetznercloud/hcloud-python Home-page: https://github.com/hetznercloud/hcloud-python
Author: Hetzner Cloud GmbH Author: Hetzner Cloud GmbH
......
VERSION = "1.18.2" VERSION = "1.19.0"
...@@ -169,6 +169,7 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin): ...@@ -169,6 +169,7 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin):
label_selector=None, # type: Optional[str] label_selector=None, # type: Optional[str]
bound_to=None, # type: Optional[List[str]] bound_to=None, # type: Optional[List[str]]
type=None, # type: Optional[List[str]] type=None, # type: Optional[List[str]]
architecture=None, # type: Optional[List[str]]
sort=None, # type: Optional[List[str]] sort=None, # type: Optional[List[str]]
page=None, # type: Optional[int] page=None, # type: Optional[int]
per_page=None, # type: Optional[int] per_page=None, # type: Optional[int]
...@@ -186,6 +187,8 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin): ...@@ -186,6 +187,8 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin):
Server Id linked to the image. Only available for images of type backup Server Id linked to the image. Only available for images of type backup
:param type: List[str] (optional) :param type: List[str] (optional)
Choices: system snapshot backup Choices: system snapshot backup
:param architecture: List[str] (optional)
Choices: x86 arm
:param status: List[str] (optional) :param status: List[str] (optional)
Can be used to filter images by their status. The response will only contain images matching the status. Can be used to filter images by their status. The response will only contain images matching the status.
:param sort: List[str] (optional) :param sort: List[str] (optional)
...@@ -207,6 +210,8 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin): ...@@ -207,6 +210,8 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin):
params["bound_to"] = bound_to params["bound_to"] = bound_to
if type is not None: if type is not None:
params["type"] = type params["type"] = type
if architecture is not None:
params["architecture"] = architecture
if sort is not None: if sort is not None:
params["sort"] = sort params["sort"] = sort
if page is not None: if page is not None:
...@@ -228,6 +233,7 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin): ...@@ -228,6 +233,7 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin):
label_selector=None, # type: Optional[str] label_selector=None, # type: Optional[str]
bound_to=None, # type: Optional[List[str]] bound_to=None, # type: Optional[List[str]]
type=None, # type: Optional[List[str]] type=None, # type: Optional[List[str]]
architecture=None, # type: Optional[List[str]]
sort=None, # type: Optional[List[str]] sort=None, # type: Optional[List[str]]
status=None, # type: Optional[List[str]] status=None, # type: Optional[List[str]]
include_deprecated=None, # type: Optional[bool] include_deprecated=None, # type: Optional[bool]
...@@ -243,6 +249,8 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin): ...@@ -243,6 +249,8 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin):
Server Id linked to the image. Only available for images of type backup Server Id linked to the image. Only available for images of type backup
:param type: List[str] (optional) :param type: List[str] (optional)
Choices: system snapshot backup Choices: system snapshot backup
:param architecture: List[str] (optional)
Choices: x86 arm
:param status: List[str] (optional) :param status: List[str] (optional)
Can be used to filter images by their status. The response will only contain images matching the status. Can be used to filter images by their status. The response will only contain images matching the status.
:param sort: List[str] (optional) :param sort: List[str] (optional)
...@@ -256,6 +264,7 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin): ...@@ -256,6 +264,7 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin):
label_selector=label_selector, label_selector=label_selector,
bound_to=bound_to, bound_to=bound_to,
type=type, type=type,
architecture=architecture,
sort=sort, sort=sort,
status=status, status=status,
include_deprecated=include_deprecated, include_deprecated=include_deprecated,
...@@ -265,12 +274,29 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin): ...@@ -265,12 +274,29 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin):
# type: (str) -> BoundImage # type: (str) -> BoundImage
"""Get image by name """Get image by name
Deprecated: Use get_by_name_and_architecture instead.
:param name: str :param name: str
Used to get image by name. Used to get image by name.
:return: :class:`BoundImage <hcloud.images.client.BoundImage>` :return: :class:`BoundImage <hcloud.images.client.BoundImage>`
""" """
return super(ImagesClient, self).get_by_name(name) return super(ImagesClient, self).get_by_name(name)
def get_by_name_and_architecture(self, name, architecture):
# type: (str, str) -> BoundImage
"""Get image by name
:param name: str
Used to identify the image.
:param architecture: str
Used to identify the image.
:return: :class:`BoundImage <hcloud.images.client.BoundImage>`
"""
response = self.get_list(name=name, architecture=[architecture])
entities = getattr(response, self.results_list_attribute_name)
entity = entities[0] if entities else None
return entity
def update(self, image, description=None, type=None, labels=None): def update(self, image, description=None, type=None, labels=None):
# type:(Image, Optional[str], Optional[str], Optional[Dict[str, str]]) -> BoundImage # type:(Image, Optional[str], Optional[str], Optional[Dict[str, str]]) -> BoundImage
"""Updates the Image. You may change the description, convert a Backup image to a Snapshot Image or change the image labels. """Updates the Image. You may change the description, convert a Backup image to a Snapshot Image or change the image labels.
...@@ -311,7 +337,7 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin): ...@@ -311,7 +337,7 @@ class ImagesClient(ClientEntityBase, GetEntityByNameMixin):
return True return True
def change_protection(self, image, delete=None): def change_protection(self, image, delete=None):
# type: (Image, Optional[bool], Optional[bool]) -> BoundAction # type: (Image, Optional[bool]) -> BoundAction
"""Changes the protection configuration of the image. Can only be used on snapshots. """Changes the protection configuration of the image. Can only be used on snapshots.
:param image: :class:`BoundImage <hcloud.images.client.BoundImage>` or :class:`Image <hcloud.images.domain.Image>` :param image: :class:`BoundImage <hcloud.images.client.BoundImage>` or :class:`Image <hcloud.images.domain.Image>`
......
...@@ -30,6 +30,8 @@ class Image(BaseDomain, DomainIdentityMixin): ...@@ -30,6 +30,8 @@ class Image(BaseDomain, DomainIdentityMixin):
Flavor of operating system contained in the image Choices: `ubuntu`, `centos`, `debian`, `fedora`, `unknown` Flavor of operating system contained in the image Choices: `ubuntu`, `centos`, `debian`, `fedora`, `unknown`
:param os_version: str, None :param os_version: str, None
Operating system version Operating system version
:param architecture: str
CPU Architecture that the image is compatible with. Choices: `x86`, `arm`
:param rapid_deploy: bool :param rapid_deploy: bool
Indicates that rapid deploy of the image is available Indicates that rapid deploy of the image is available
:param protection: dict :param protection: dict
...@@ -50,6 +52,7 @@ class Image(BaseDomain, DomainIdentityMixin): ...@@ -50,6 +52,7 @@ class Image(BaseDomain, DomainIdentityMixin):
"bound_to", "bound_to",
"os_flavor", "os_flavor",
"os_version", "os_version",
"architecture",
"rapid_deploy", "rapid_deploy",
"created_from", "created_from",
"status", "status",
...@@ -72,6 +75,7 @@ class Image(BaseDomain, DomainIdentityMixin): ...@@ -72,6 +75,7 @@ class Image(BaseDomain, DomainIdentityMixin):
bound_to=None, bound_to=None,
os_flavor=None, os_flavor=None,
os_version=None, os_version=None,
architecture=None,
rapid_deploy=None, rapid_deploy=None,
created_from=None, created_from=None,
protection=None, protection=None,
...@@ -89,6 +93,7 @@ class Image(BaseDomain, DomainIdentityMixin): ...@@ -89,6 +93,7 @@ class Image(BaseDomain, DomainIdentityMixin):
self.bound_to = bound_to self.bound_to = bound_to
self.os_flavor = os_flavor self.os_flavor = os_flavor
self.os_version = os_version self.os_version = os_version
self.architecture = architecture
self.rapid_deploy = rapid_deploy self.rapid_deploy = rapid_deploy
self.created_from = created_from self.created_from = created_from
self.protection = protection self.protection = protection
......
...@@ -25,6 +25,8 @@ class IsosClient(ClientEntityBase, GetEntityByNameMixin): ...@@ -25,6 +25,8 @@ class IsosClient(ClientEntityBase, GetEntityByNameMixin):
def get_list( def get_list(
self, self,
name=None, # type: Optional[str] name=None, # type: Optional[str]
architecture=None, # type: Optional[List[str]]
include_wildcard_architecture=None, # type: Optional[bool]
page=None, # type: Optional[int] page=None, # type: Optional[int]
per_page=None, # type: Optional[int] per_page=None, # type: Optional[int]
): ):
...@@ -33,6 +35,11 @@ class IsosClient(ClientEntityBase, GetEntityByNameMixin): ...@@ -33,6 +35,11 @@ class IsosClient(ClientEntityBase, GetEntityByNameMixin):
:param name: str (optional) :param name: str (optional)
Can be used to filter ISOs by their name. Can be used to filter ISOs by their name.
:param architecture: List[str] (optional)
Can be used to filter ISOs by their architecture. Choices: x86 arm
:param include_wildcard_architecture: bool (optional)
Custom ISOs do not have an architecture set. You must also set this flag to True if you are filtering by
architecture and also want custom ISOs.
:param page: int (optional) :param page: int (optional)
Specifies the page to fetch Specifies the page to fetch
:param per_page: int (optional) :param per_page: int (optional)
...@@ -42,6 +49,10 @@ class IsosClient(ClientEntityBase, GetEntityByNameMixin): ...@@ -42,6 +49,10 @@ class IsosClient(ClientEntityBase, GetEntityByNameMixin):
params = {} params = {}
if name is not None: if name is not None:
params["name"] = name params["name"] = name
if architecture is not None:
params["architecture"] = architecture
if include_wildcard_architecture is not None:
params["include_wildcard_architecture"] = include_wildcard_architecture
if page is not None: if page is not None:
params["page"] = page params["page"] = page
if per_page is not None: if per_page is not None:
...@@ -51,15 +62,29 @@ class IsosClient(ClientEntityBase, GetEntityByNameMixin): ...@@ -51,15 +62,29 @@ class IsosClient(ClientEntityBase, GetEntityByNameMixin):
isos = [BoundIso(self, iso_data) for iso_data in response["isos"]] isos = [BoundIso(self, iso_data) for iso_data in response["isos"]]
return self._add_meta_to_result(isos, response) return self._add_meta_to_result(isos, response)
def get_all(self, name=None): def get_all(
# type: (Optional[str]) -> List[BoundIso] self,
name=None, # type: Optional[str]
architecture=None, # type: Optional[List[str]]
include_wildcard_architecture=None, # type: Optional[bool]
):
# type: (...) -> List[BoundIso]
"""Get all ISOs """Get all ISOs
:param name: str (optional) :param name: str (optional)
Can be used to filter ISOs by their name. Can be used to filter ISOs by their name.
:param architecture: List[str] (optional)
Can be used to filter ISOs by their architecture. Choices: x86 arm
:param include_wildcard_architecture: bool (optional)
Custom ISOs do not have an architecture set. You must also set this flag to True if you are filtering by
architecture and also want custom ISOs.
:return: List[:class:`BoundIso <hcloud.isos.client.BoundIso>`] :return: List[:class:`BoundIso <hcloud.isos.client.BoundIso>`]
""" """
return super(IsosClient, self).get_all(name=name) return super(IsosClient, self).get_all(
name=name,
architecture=architecture,
include_wildcard_architecture=include_wildcard_architecture,
)
def get_by_name(self, name): def get_by_name(self, name):
# type: (str) -> BoundIso # type: (str) -> BoundIso
......
...@@ -14,17 +14,26 @@ class Iso(BaseDomain, DomainIdentityMixin): ...@@ -14,17 +14,26 @@ class Iso(BaseDomain, DomainIdentityMixin):
Description of the ISO Description of the ISO
:param type: str :param type: str
Type of the ISO. Choices: `public`, `private` Type of the ISO. Choices: `public`, `private`
:param architecture: str, None
CPU Architecture that the ISO is compatible with. None means that the compatibility is unknown. Choices: `x86`, `arm`
:param deprecated: datetime, None :param deprecated: datetime, None
ISO 8601 timestamp of deprecation, None if ISO is still available. After the deprecation time it will no longer be possible to attach the ISO to servers. ISO 8601 timestamp of deprecation, None if ISO is still available. After the deprecation time it will no longer be possible to attach the ISO to servers.
""" """
__slots__ = ("id", "name", "type", "description", "deprecated") __slots__ = ("id", "name", "type", "architecture", "description", "deprecated")
def __init__( def __init__(
self, id=None, name=None, type=None, description=None, deprecated=None self,
id=None,
name=None,
type=None,
architecture=None,
description=None,
deprecated=None,
): ):
self.id = id self.id = id
self.name = name self.name = name
self.type = type self.type = type
self.architecture = architecture
self.description = description self.description = description
self.deprecated = isoparse(deprecated) if deprecated else None self.deprecated = isoparse(deprecated) if deprecated else None
...@@ -22,6 +22,8 @@ class ServerType(BaseDomain, DomainIdentityMixin): ...@@ -22,6 +22,8 @@ class ServerType(BaseDomain, DomainIdentityMixin):
Type of server boot drive. Local has higher speed. Network has better availability. Choices: `local`, `network` Type of server boot drive. Local has higher speed. Network has better availability. Choices: `local`, `network`
:param cpu_type: string :param cpu_type: string
Type of cpu. Choices: `shared`, `dedicated` Type of cpu. Choices: `shared`, `dedicated`
:param architecture: string
Architecture of cpu. Choices: `x86`, `arm`
:param deprecated: bool :param deprecated: bool
True if server type is deprecated True if server type is deprecated
""" """
...@@ -36,6 +38,7 @@ class ServerType(BaseDomain, DomainIdentityMixin): ...@@ -36,6 +38,7 @@ class ServerType(BaseDomain, DomainIdentityMixin):
"prices", "prices",
"storage_type", "storage_type",
"cpu_type", "cpu_type",
"architecture",
"deprecated", "deprecated",
) )
...@@ -50,6 +53,7 @@ class ServerType(BaseDomain, DomainIdentityMixin): ...@@ -50,6 +53,7 @@ class ServerType(BaseDomain, DomainIdentityMixin):
prices=None, prices=None,
storage_type=None, storage_type=None,
cpu_type=None, cpu_type=None,
architecture=None,
deprecated=None, deprecated=None,
): ):
self.id = id self.id = id
...@@ -61,4 +65,5 @@ class ServerType(BaseDomain, DomainIdentityMixin): ...@@ -61,4 +65,5 @@ class ServerType(BaseDomain, DomainIdentityMixin):
self.prices = prices self.prices = prices
self.storage_type = storage_type self.storage_type = storage_type
self.cpu_type = cpu_type self.cpu_type = cpu_type
self.architecture = architecture
self.deprecated = deprecated self.deprecated = deprecated
...@@ -40,7 +40,7 @@ class Server(BaseDomain): ...@@ -40,7 +40,7 @@ class Server(BaseDomain):
User-defined labels (key-value pairs) User-defined labels (key-value pairs)
:param volumes: List[:class:`BoundVolume <hcloud.volumes.client.BoundVolume>`] :param volumes: List[:class:`BoundVolume <hcloud.volumes.client.BoundVolume>`]
Volumes assigned to this server. Volumes assigned to this server.
:param private_net: List[:class:`PrivateNet <hcloud.servers.domain.PrivateNet`] :param private_net: List[:class:`PrivateNet <hcloud.servers.domain.PrivateNet>`]
Private networks information. Private networks information.
""" """
......
...@@ -17,6 +17,7 @@ def image_response(): ...@@ -17,6 +17,7 @@ def image_response():
"bound_to": 1, "bound_to": 1,
"os_flavor": "ubuntu", "os_flavor": "ubuntu",
"os_version": "16.04", "os_version": "16.04",
"architecture": "x86",
"rapid_deploy": False, "rapid_deploy": False,
"protection": {"delete": False}, "protection": {"delete": False},
"deprecated": "2018-02-28T00:00:00+00:00", "deprecated": "2018-02-28T00:00:00+00:00",
...@@ -42,6 +43,7 @@ def two_images_response(): ...@@ -42,6 +43,7 @@ def two_images_response():
"bound_to": None, "bound_to": None,
"os_flavor": "ubuntu", "os_flavor": "ubuntu",
"os_version": "16.04", "os_version": "16.04",
"architecture": "x86",
"rapid_deploy": False, "rapid_deploy": False,
"protection": {"delete": False}, "protection": {"delete": False},
"deprecated": "2018-02-28T00:00:00+00:00", "deprecated": "2018-02-28T00:00:00+00:00",
...@@ -60,6 +62,7 @@ def two_images_response(): ...@@ -60,6 +62,7 @@ def two_images_response():
"bound_to": None, "bound_to": None,
"os_flavor": "ubuntu", "os_flavor": "ubuntu",
"os_version": "16.04", "os_version": "16.04",
"architecture": "x86",
"rapid_deploy": False, "rapid_deploy": False,
"protection": {"delete": False}, "protection": {"delete": False},
"deprecated": "2018-02-28T00:00:00+00:00", "deprecated": "2018-02-28T00:00:00+00:00",
...@@ -86,6 +89,7 @@ def one_images_response(): ...@@ -86,6 +89,7 @@ def one_images_response():
"bound_to": None, "bound_to": None,
"os_flavor": "ubuntu", "os_flavor": "ubuntu",
"os_version": "16.04", "os_version": "16.04",
"architecture": "x86",
"rapid_deploy": False, "rapid_deploy": False,
"protection": {"delete": False}, "protection": {"delete": False},
"deprecated": "2018-02-28T00:00:00+00:00", "deprecated": "2018-02-28T00:00:00+00:00",
...@@ -111,6 +115,7 @@ def response_update_image(): ...@@ -111,6 +115,7 @@ def response_update_image():
"bound_to": None, "bound_to": None,
"os_flavor": "ubuntu", "os_flavor": "ubuntu",
"os_version": "16.04", "os_version": "16.04",
"architecture": "arm",
"rapid_deploy": False, "rapid_deploy": False,
"protection": {"delete": False}, "protection": {"delete": False},
"deprecated": "2018-02-28T00:00:00+00:00", "deprecated": "2018-02-28T00:00:00+00:00",
......
...@@ -29,6 +29,7 @@ class TestBoundImage(object): ...@@ -29,6 +29,7 @@ class TestBoundImage(object):
) )
assert bound_image.os_flavor == "ubuntu" assert bound_image.os_flavor == "ubuntu"
assert bound_image.os_version == "16.04" assert bound_image.os_version == "16.04"
assert bound_image.architecture == "x86"
assert bound_image.rapid_deploy is False assert bound_image.rapid_deploy is False
assert bound_image.deprecated == datetime.datetime( assert bound_image.deprecated == datetime.datetime(
2018, 2, 28, 0, 0, tzinfo=tzoffset(None, 0) 2018, 2, 28, 0, 0, tzinfo=tzoffset(None, 0)
...@@ -223,6 +224,21 @@ class TestImagesClient(object): ...@@ -223,6 +224,21 @@ class TestImagesClient(object):
assert image.id == 4711 assert image.id == 4711
assert image.name == "ubuntu-20.04" assert image.name == "ubuntu-20.04"
def test_get_by_name_and_architecture(self, images_client, one_images_response):
images_client._client.request.return_value = one_images_response
image = images_client.get_by_name_and_architecture("ubuntu-20.04", "x86")
params = {"name": "ubuntu-20.04", "architecture": ["x86"]}
images_client._client.request.assert_called_with(
url="/images", method="GET", params=params
)
assert image._client is images_client
assert image.id == 4711
assert image.name == "ubuntu-20.04"
assert image.architecture == "x86"
@pytest.mark.parametrize( @pytest.mark.parametrize(
"image", [Image(id=1), BoundImage(mock.MagicMock(), dict(id=1))] "image", [Image(id=1), BoundImage(mock.MagicMock(), dict(id=1))]
) )
......
...@@ -9,6 +9,7 @@ def iso_response(): ...@@ -9,6 +9,7 @@ def iso_response():
"name": "FreeBSD-11.0-RELEASE-amd64-dvd1", "name": "FreeBSD-11.0-RELEASE-amd64-dvd1",
"description": "FreeBSD 11.0 x64", "description": "FreeBSD 11.0 x64",
"type": "public", "type": "public",
"architecture": "x86",
"deprecated": "2018-02-28T00:00:00+00:00", "deprecated": "2018-02-28T00:00:00+00:00",
} }
} }
...@@ -23,6 +24,7 @@ def two_isos_response(): ...@@ -23,6 +24,7 @@ def two_isos_response():
"name": "FreeBSD-11.0-RELEASE-amd64-dvd1", "name": "FreeBSD-11.0-RELEASE-amd64-dvd1",
"description": "FreeBSD 11.0 x64", "description": "FreeBSD 11.0 x64",
"type": "public", "type": "public",
"architecture": "x86",
"deprecated": "2018-02-28T00:00:00+00:00", "deprecated": "2018-02-28T00:00:00+00:00",
}, },
{ {
...@@ -30,6 +32,7 @@ def two_isos_response(): ...@@ -30,6 +32,7 @@ def two_isos_response():
"name": "FreeBSD-11.0-RELEASE-amd64-dvd1", "name": "FreeBSD-11.0-RELEASE-amd64-dvd1",
"description": "FreeBSD 11.0 x64", "description": "FreeBSD 11.0 x64",
"type": "public", "type": "public",
"architecture": "x86",
"deprecated": "2018-02-28T00:00:00+00:00", "deprecated": "2018-02-28T00:00:00+00:00",
}, },
] ]
...@@ -45,6 +48,7 @@ def one_isos_response(): ...@@ -45,6 +48,7 @@ def one_isos_response():
"name": "FreeBSD-11.0-RELEASE-amd64-dvd1", "name": "FreeBSD-11.0-RELEASE-amd64-dvd1",
"description": "FreeBSD 11.0 x64", "description": "FreeBSD 11.0 x64",
"type": "public", "type": "public",
"architecture": "x86",
"deprecated": "2018-02-28T00:00:00+00:00", "deprecated": "2018-02-28T00:00:00+00:00",
} }
] ]
......
...@@ -18,6 +18,7 @@ class TestBoundIso(object): ...@@ -18,6 +18,7 @@ class TestBoundIso(object):
assert bound_iso.name == "FreeBSD-11.0-RELEASE-amd64-dvd1" assert bound_iso.name == "FreeBSD-11.0-RELEASE-amd64-dvd1"
assert bound_iso.description == "FreeBSD 11.0 x64" assert bound_iso.description == "FreeBSD 11.0 x64"
assert bound_iso.type == "public" assert bound_iso.type == "public"
assert bound_iso.architecture == "x86"
assert bound_iso.deprecated == datetime.datetime( assert bound_iso.deprecated == datetime.datetime(
2018, 2, 28, 0, 0, tzinfo=tzoffset(None, 0) 2018, 2, 28, 0, 0, tzinfo=tzoffset(None, 0)
) )
......
...@@ -26,6 +26,7 @@ def server_type_response(): ...@@ -26,6 +26,7 @@ def server_type_response():
], ],
"storage_type": "local", "storage_type": "local",
"cpu_type": "shared", "cpu_type": "shared",
"architecture": "x86",
} }
} }
...@@ -56,6 +57,7 @@ def two_server_types_response(): ...@@ -56,6 +57,7 @@ def two_server_types_response():
], ],
"storage_type": "local", "storage_type": "local",
"cpu_type": "shared", "cpu_type": "shared",
"architecture": "x86",
}, },
{ {
"id": 2, "id": 2,
...@@ -90,6 +92,7 @@ def two_server_types_response(): ...@@ -90,6 +92,7 @@ def two_server_types_response():
], ],
"storage_type": "local", "storage_type": "local",
"cpu_type": "shared", "cpu_type": "shared",
"architecture": "x86",
}, },
] ]
} }
...@@ -121,6 +124,7 @@ def one_server_types_response(): ...@@ -121,6 +124,7 @@ def one_server_types_response():
], ],
"storage_type": "local", "storage_type": "local",
"cpu_type": "shared", "cpu_type": "shared",
"architecture": "x86",
} }
] ]
} }
...@@ -2,7 +2,28 @@ import pytest ...@@ -2,7 +2,28 @@ import pytest
from unittest import mock from unittest import mock
from hcloud.server_types.client import ServerTypesClient from hcloud.server_types.client import ServerTypesClient, BoundServerType
class TestBoundIso(object):
@pytest.fixture()
def bound_server_type(self, hetzner_client):
return BoundServerType(client=hetzner_client.server_types, data=dict(id=14))
def test_bound_server_type_init(self, server_type_response):
bound_server_type = BoundServerType(
client=mock.MagicMock(), data=server_type_response["server_type"]
)
assert bound_server_type.id == 1
assert bound_server_type.name == "cx11"
assert bound_server_type.description == "CX11"
assert bound_server_type.cores == 1
assert bound_server_type.memory == 1
assert bound_server_type.disk == 25
assert bound_server_type.storage_type == "local"
assert bound_server_type.cpu_type == "shared"
assert bound_server_type.architecture == "x86"
class TestServerTypesClient(object): class TestServerTypesClient(object):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment