Skip to content

Commit decbc3a

Browse files
committed
Run flake8 on tests/ folder
1 parent c3a0a3d commit decbc3a

13 files changed

Lines changed: 73 additions & 81 deletions

File tree

tests/integration/actions/test_actions.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import mock
2-
import pytest
3-
41

52
class TestActionsClient(object):
63
def test_get_by_id(self, hetzner_client):

tests/integration/server_types/test_server_types.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import pytest
2-
import mock
3-
41

52
class TestServerTypesClient(object):
63

@@ -50,4 +47,4 @@ def test_get_all(self, hetzner_client):
5047
}
5148
]
5249
assert server_types[0].storage_type == "local"
53-
assert server_types[0].cpu_type == "shared"
50+
assert server_types[0].cpu_type == "shared"

tests/integration/servers/test_servers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from hcloud.iso.domain import Iso
99
from hcloud.server_types.domain import ServerType
1010

11+
1112
class TestBoundServer(object):
1213

1314
@pytest.fixture()
@@ -283,7 +284,7 @@ def test_create_image(self, hetzner_client, server):
283284
assert response.image.description == "my image"
284285

285286
@pytest.mark.parametrize("server", [Server(id=1), BoundServer(mock.MagicMock(), dict(id=1))])
286-
def test_enable_backup(self, hetzner_client, server):
287+
def test_rebuild(self, hetzner_client, server):
287288
action = hetzner_client.servers.rebuild(server, Image(name="ubuntu-16.04"))
288289

289290
assert action.id == 13

tests/unit/actions/test_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@ def test_get_all_no_params(self, actions_client, generic_action_list):
3535
assert action2._client is actions_client
3636
assert action2.id == 2
3737
assert action2.command == "stop_server"
38-

tests/unit/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def mocked_requests():
99
yield mocked_requests
1010
patcher.stop()
1111

12+
1213
@pytest.fixture()
1314
def generic_action():
1415
return {
@@ -30,4 +31,4 @@ def generic_action():
3031
"message": "Action failed"
3132
}
3233
}
33-
}
34+
}

tests/unit/core/test_client.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ def test_get_filled_model_attribute_incomplete_model(self, bound_model_class, cl
5353
assert id == 101
5454
assert bound_model.complete is False
5555

56-
5756
def test_get_non_exists_model_attribute_incomplete_model(self, bound_model_class, client):
5857
bound_model = bound_model_class(client=client, data={"id": 1}, complete=False)
5958
with pytest.raises(AttributeError):
6059
bound_model.content
6160
client.get_by_id.assert_not_called()
6261
assert bound_model.complete is False
63-

tests/unit/helpers/test_descriptors.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ def test_created_assigned_valid(self, entity_with_descriptor):
2727
entity.created = "2016-01-30T23:50+00:00"
2828
assert entity.created == datetime.datetime(2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0))
2929

30-
3130
def test_created_valid(self, entity_with_descriptor):
3231
entity = entity_with_descriptor(created="2016-01-30T23:50+00:00")
3332
assert entity.created == datetime.datetime(2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0))
3433

3534
def test_created_invalid(self, entity_with_descriptor):
36-
with pytest.raises(ValueError) as e:
35+
with pytest.raises(ValueError):
3736
entity_with_descriptor(created="invalid")

tests/unit/server_types/test_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,3 @@ def test_get_all_no_params(self, server_types_client, two_server_types_response)
4141
def test_get_all_with_params(self, server_types_client, params):
4242
server_types_client.get_all(**params)
4343
server_types_client._client.request.assert_called_with(url="/server_types", method="GET", params=params)
44-

tests/unit/servers/conftest.py

Lines changed: 61 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -379,73 +379,71 @@ def response_simple_servers():
379379
"protection": {},
380380
"labels": {},
381381
"volumes": []
382-
},
383-
{
384-
"id": 2,
385-
"name": "my-server2",
386-
"status": "running",
387-
"created": "2016-03-30T23:50+00:00",
388-
"public_net": {},
389-
"server_type": {
390-
"id": 1,
391-
"name": "cx11",
392-
"description": "CX11",
393-
"cores": 1,
394-
"memory": 1,
395-
"disk": 25,
396-
"prices": [
397-
{
398-
"location": "fsn1",
399-
"price_hourly": {
400-
"net": "1.0000000000",
401-
"gross": "1.1900000000000000"
402-
},
403-
"price_monthly": {
404-
"net": "1.0000000000",
405-
"gross": "1.1900000000000000"
406-
}
382+
}, {
383+
"id": 2,
384+
"name": "my-server2",
385+
"status": "running",
386+
"created": "2016-03-30T23:50+00:00",
387+
"public_net": {},
388+
"server_type": {
389+
"id": 1,
390+
"name": "cx11",
391+
"description": "CX11",
392+
"cores": 1,
393+
"memory": 1,
394+
"disk": 25,
395+
"prices": [
396+
{
397+
"location": "fsn1",
398+
"price_hourly": {
399+
"net": "1.0000000000",
400+
"gross": "1.1900000000000000"
401+
},
402+
"price_monthly": {
403+
"net": "1.0000000000",
404+
"gross": "1.1900000000000000"
407405
}
408-
],
409-
"storage_type": "local",
410-
"cpu_type": "shared"
406+
}
407+
],
408+
"storage_type": "local",
409+
"cpu_type": "shared"
410+
},
411+
"datacenter": {},
412+
"image": {
413+
"id": 4711,
414+
"type": "snapshot",
415+
"status": "available",
416+
"name": "ubuntu-16.04",
417+
"description": "Ubuntu 16.04 Standard 64 bit",
418+
"image_size": 2.3,
419+
"disk_size": 10,
420+
"created": "2016-01-30T23:50+00:00",
421+
"created_from": {
422+
"id": 1,
423+
"name": "Server"
411424
},
412-
"datacenter": {},
413-
"image": {
414-
"id": 4711,
415-
"type": "snapshot",
416-
"status": "available",
417-
"name": "ubuntu-16.04",
418-
"description": "Ubuntu 16.04 Standard 64 bit",
419-
"image_size": 2.3,
420-
"disk_size": 10,
421-
"created": "2016-01-30T23:50+00:00",
422-
"created_from": {
423-
"id": 1,
424-
"name": "Server"
425-
},
426-
"bound_to": None,
427-
"os_flavor": "ubuntu",
428-
"os_version": "16.04",
429-
"rapid_deploy": False,
430-
"protection": {
431-
"delete": False,
432-
"rebuild": False
433-
},
434-
"deprecated": "2018-02-28T00:00:00+00:00",
435-
"labels": {}
425+
"bound_to": None,
426+
"os_flavor": "ubuntu",
427+
"os_version": "16.04",
428+
"rapid_deploy": False,
429+
"protection": {
430+
"delete": False,
431+
"rebuild": False
436432
},
437-
"iso": None,
438-
"rescue_enabled": False,
439-
"locked": False,
440-
"backup_window": "22-02",
441-
"outgoing_traffic": 123456,
442-
"ingoing_traffic": 123456,
443-
"included_traffic": 654321,
444-
"protection": {},
445-
"labels": {},
446-
"volumes": []
433+
"deprecated": "2018-02-28T00:00:00+00:00",
434+
"labels": {}
447435
},
448-
]
436+
"iso": None,
437+
"rescue_enabled": False,
438+
"locked": False,
439+
"backup_window": "22-02",
440+
"outgoing_traffic": 123456,
441+
"ingoing_traffic": 123456,
442+
"included_traffic": 654321,
443+
"protection": {},
444+
"labels": {},
445+
"volumes": []
446+
}]
449447
}
450448

451449

tests/unit/servers/test_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_get_actions(self, hetzner_client, bound_server, response_get_actions):
8080
def test_update(self, hetzner_client, bound_server, response_update_server):
8181
hetzner_client.request.return_value = response_update_server
8282
server = bound_server.update(name="new-name", labels={})
83-
hetzner_client.request.assert_called_with(url="/servers/14", method="PUT",json={"name": "new-name", "labels": {}})
83+
hetzner_client.request.assert_called_with(url="/servers/14", method="PUT", json={"name": "new-name", "labels": {}})
8484

8585
assert server.id == 14
8686
assert server.name == "new-name"
@@ -339,6 +339,8 @@ def test_create_with_volumes(self, servers_client, response_create_simple_server
339339
next_actions = response.next_actions
340340
root_password = response.root_password
341341

342+
assert root_password == "YItygq1v3GYjjMomLaKc"
343+
342344
assert bound_server._client is servers_client
343345
assert bound_server.id == 1
344346
assert bound_server.name == "my-server"

0 commit comments

Comments
 (0)