|
9 | 9 | from hcloud.load_balancers.client import BoundLoadBalancer, LoadBalancersClient |
10 | 10 |
|
11 | 11 | from hcloud.load_balancers.domain import LoadBalancerAlgorithm, LoadBalancerHealthCheck, \ |
12 | | - LoadBalancerService, LoadBalancerTarget |
| 12 | + LoadBalancerService, LoadBalancerTarget, LoadBalancer |
13 | 13 | from hcloud.actions.client import BoundAction |
14 | 14 |
|
15 | 15 |
|
@@ -206,6 +206,14 @@ def test_detach_from_network(self, response_detach_from_network, hetzner_client, |
206 | 206 | assert action.progress == 100 |
207 | 207 | assert action.command == "detach_from_network" |
208 | 208 |
|
| 209 | + def test_change_type(self, hetzner_client, bound_load_balancer, generic_action): |
| 210 | + hetzner_client.request.return_value = generic_action |
| 211 | + action = bound_load_balancer.change_type(LoadBalancerType(name="lb21")) |
| 212 | + hetzner_client.request.assert_called_with(url="/load_balancers/14/actions/change_type", method="POST", json={"load_balancer_type": "lb21"}) |
| 213 | + |
| 214 | + assert action.id == 1 |
| 215 | + assert action.progress == 0 |
| 216 | + |
209 | 217 |
|
210 | 218 | class TestLoadBalancerslient(object): |
211 | 219 |
|
@@ -315,3 +323,21 @@ def test_create(self, load_balancers_client, response_create_load_balancer): |
315 | 323 | assert bound_load_balancer._client is load_balancers_client |
316 | 324 | assert bound_load_balancer.id == 1 |
317 | 325 | assert bound_load_balancer.name == "my-balancer" |
| 326 | + |
| 327 | + @pytest.mark.parametrize("load_balancer", [LoadBalancer(id=1), BoundLoadBalancer(mock.MagicMock(), dict(id=1))]) |
| 328 | + def test_change_type_with_load_balancer_type_name(self, load_balancers_client, load_balancer, generic_action): |
| 329 | + load_balancers_client._client.request.return_value = generic_action |
| 330 | + action = load_balancers_client.change_type(load_balancer, LoadBalancerType(name="lb11")) |
| 331 | + load_balancers_client._client.request.assert_called_with(url="/load_balancers/1/actions/change_type", method="POST", json={"load_balancer_type": "lb11"}) |
| 332 | + |
| 333 | + assert action.id == 1 |
| 334 | + assert action.progress == 0 |
| 335 | + |
| 336 | + @pytest.mark.parametrize("load_balancer", [LoadBalancer(id=1), BoundLoadBalancer(mock.MagicMock(), dict(id=1))]) |
| 337 | + def test_change_type_with_load_balancer_type_id(self, load_balancers_client, load_balancer, generic_action): |
| 338 | + load_balancers_client._client.request.return_value = generic_action |
| 339 | + action = load_balancers_client.change_type(load_balancer, LoadBalancerType(id=1)) |
| 340 | + load_balancers_client._client.request.assert_called_with(url="/load_balancers/1/actions/change_type", method="POST", json={"load_balancer_type": 1}) |
| 341 | + |
| 342 | + assert action.id == 1 |
| 343 | + assert action.progress == 0 |
0 commit comments