Skip to content

Commit d7fdb73

Browse files
committed
Add network_zone to Locations
1 parent fae18c8 commit d7fdb73

4 files changed

Lines changed: 22 additions & 8 deletions

File tree

hcloud/locations/domain.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Location(BaseDomain, DomainIdentityMixin):
1919
Latitude of the city closest to the location
2020
:param longitude: float
2121
Longitude of the city closest to the location
22+
:param network_zone: str
23+
Name of network zone this location resides in
2224
"""
2325

2426
__slots__ = (
@@ -28,7 +30,8 @@ class Location(BaseDomain, DomainIdentityMixin):
2830
"country",
2931
"city",
3032
"latitude",
31-
"longitude"
33+
"longitude",
34+
"network_zone"
3235
)
3336

3437
def __init__(
@@ -39,7 +42,8 @@ def __init__(
3942
country=None,
4043
city=None,
4144
latitude=None,
42-
longitude=None
45+
longitude=None,
46+
network_zone=None,
4347
):
4448
self.id = id
4549
self.name = name
@@ -48,3 +52,4 @@ def __init__(
4852
self.city = city
4953
self.latitude = latitude
5054
self.longitude = longitude
55+
self.network_zone = network_zone

tests/unit/locations/conftest.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def location_response():
1111
"country": "DE",
1212
"city": "Falkenstein",
1313
"latitude": 50.47612,
14-
"longitude": 12.370071
14+
"longitude": 12.370071,
15+
"network_zone": "eu-central",
1516
}
1617
}
1718

@@ -28,7 +29,8 @@ def two_locations_response():
2829
"country": "DE",
2930
"city": "Falkenstein",
3031
"latitude": 50.47612,
31-
"longitude": 12.370071
32+
"longitude": 12.370071,
33+
"network_zone": "eu-central",
3234

3335
},
3436
{
@@ -38,7 +40,8 @@ def two_locations_response():
3840
"country": "DE",
3941
"city": "Nuremberg",
4042
"latitude": 49.452102,
41-
"longitude": 11.076665
43+
"longitude": 11.076665,
44+
"network_zone": "eu-central",
4245
}
4346
]
4447
}
@@ -56,8 +59,8 @@ def one_locations_response():
5659
"country": "DE",
5760
"city": "Falkenstein",
5861
"latitude": 50.47612,
59-
"longitude": 12.370071
60-
62+
"longitude": 12.370071,
63+
"network_zone": "eu-central",
6164
}
6265
]
6366
}

tests/unit/locations/test_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def test_get_by_id(self, locations_client, location_response):
1717
assert location._client is locations_client
1818
assert location.id == 1
1919
assert location.name == "fsn1"
20+
assert location.network_zone == "eu-central"
2021

2122
@pytest.mark.parametrize("params", [{'name': "fsn1", "page": 1, "per_page": 10}, {}])
2223
def test_get_list(self, locations_client, two_locations_response, params):
@@ -35,10 +36,12 @@ def test_get_list(self, locations_client, two_locations_response, params):
3536
assert location1._client is locations_client
3637
assert location1.id == 1
3738
assert location1.name == "fsn1"
39+
assert location1.network_zone == "eu-central"
3840

3941
assert location2._client is locations_client
4042
assert location2.id == 2
4143
assert location2.name == "nbg1"
44+
assert location2.network_zone == "eu-central"
4245

4346
@pytest.mark.parametrize("params", [{'name': "fsn1"}, {}])
4447
def test_get_all(self, locations_client, two_locations_response, params):
@@ -57,10 +60,12 @@ def test_get_all(self, locations_client, two_locations_response, params):
5760
assert location1._client is locations_client
5861
assert location1.id == 1
5962
assert location1.name == "fsn1"
63+
assert location1.network_zone == "eu-central"
6064

6165
assert location2._client is locations_client
6266
assert location2.id == 2
6367
assert location2.name == "nbg1"
68+
assert location2.network_zone == "eu-central"
6469

6570
def test_get_by_name(self, locations_client, one_locations_response):
6671
locations_client._client.request.return_value = one_locations_response
@@ -73,3 +78,4 @@ def test_get_by_name(self, locations_client, one_locations_response):
7378
assert location._client is locations_client
7479
assert location.id == 1
7580
assert location.name == "fsn1"
81+
assert location.network_zone == "eu-central"

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ passenv = FAKE_API_ENDPOINT
1111
deps =
1212
-r{toxinidir}/requirements/test.txt
1313
commands =
14-
pytest
14+
pytest {posargs}
1515

1616

0 commit comments

Comments
 (0)