Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Commit 5501267

Browse files
authored
Merge pull request #29 from packethost/moar-tests
Moar tests
2 parents eb7df49 + 5661ac0 commit 5501267

16 files changed

Lines changed: 140 additions & 80 deletions

.drone.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
matrix:
2+
PYTHON_VERSION:
3+
- 2.7
4+
- 3.3
5+
- 3.4
6+
- 3.5
7+
- 3.6
8+
9+
pipeline:
10+
fmt_and_lint:
11+
image: python:alpine
12+
commands:
13+
- pip install pylama yapf
14+
- yapf -dr packet | (! grep '.')
15+
- pylama packet test setup.py
16+
17+
test:
18+
image: python:${PYTHON_VERSION}-alpine
19+
commands:
20+
- pip install tox
21+
- tox

.style.yapf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[style]
2+
based_on_style = chromium
3+
column_limit = 120
4+
indent_width = 4

.travis.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
language: python
2+
python:
3+
- "2.7"
4+
- "3.3"
5+
- "3.4"
6+
- "3.5"
7+
- "3.6"
28

3-
install:
4-
- pip install .
5-
- pip install requests coverage flake8
6-
script: test/tests.sh
9+
install: pip install tox
10+
script: tox

packet/Facility.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
class Facility():
5+
56
def __init__(self, data):
67
self.id = data['id']
78
self.code = data['code']

packet/Manager.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111

1212

1313
class Manager(BaseAPI):
14+
1415
def __init__(self, auth_token, consumer_token=None):
1516
super(Manager, self).__init__(auth_token, consumer_token)
1617

1718
def call_api(self, method, type='GET', params=None):
18-
return super(Manager, self).call_api(method, type, params) # pragma: no cover
19+
return super(Manager, self).call_api(method, type, params)
1920

2021
def get_user(self):
2122
return self.call_api("user")
@@ -70,10 +71,20 @@ def list_devices(self, project_id, params={}):
7071
devices.append(device)
7172
return devices
7273

73-
def create_device(self, project_id, hostname, plan, facility,
74-
operating_system, billing_cycle='hourly', userdata='',
75-
locked=False, tags={}, features={}, ipxe_script_url='',
76-
always_pxe=False, public_ipv4_subnet_size=31):
74+
def create_device(self,
75+
project_id,
76+
hostname,
77+
plan,
78+
facility,
79+
operating_system,
80+
billing_cycle='hourly',
81+
userdata='',
82+
locked=False,
83+
tags={},
84+
features={},
85+
ipxe_script_url='',
86+
always_pxe=False,
87+
public_ipv4_subnet_size=31):
7788

7889
params = {
7990
'hostname': hostname,
@@ -152,13 +163,7 @@ def get_capacity(self):
152163
def validate_capacity(self, servers):
153164
params = {'servers': []}
154165
for server in servers:
155-
params['servers'].append(
156-
{
157-
'facility': server[0],
158-
'plan': server[1],
159-
'quantity': server[2]
160-
}
161-
)
166+
params['servers'].append({'facility': server[0], 'plan': server[1], 'quantity': server[2]})
162167

163168
try:
164169
self.call_api('/capacity', 'POST', params)

packet/OperatingSystem.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
class OperatingSystem(object):
5+
56
def __init__(self, data):
67
self.slug = data['slug']
78
self.name = data['name']

packet/Plan.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
class Plan():
5+
56
def __init__(self, data):
67
self.id = data['id']
78
self.name = data['name']

packet/Project.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ def __init__(self, data, manager):
1919
self.ssh_keys = data['ssh_keys']
2020

2121
def update(self):
22-
params = {
23-
"name": self.name
24-
}
22+
params = {"name": self.name}
2523

2624
return self.manager.call_api("projects/%s" % self.id, type='PATCH', params=params)
2725

packet/Volume.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@ def __init__(self, data, manager):
2828
self.attached_to = None
2929

3030
def update(self):
31-
params = {
32-
"description": self.description,
33-
"size": self.size,
34-
"plan": self.plan,
35-
"locked": self.locked
36-
}
31+
params = {"description": self.description, "size": self.size, "plan": self.plan.slug, "locked": self.locked}
3732

3833
return self.manager.call_api("storage/%s" % self.id, type='PATCH', params=params)
3934

packet/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
__license__ = "LGPL v3"
88
__copyright__ = "Copyright (c) 2015, Aaron Welch and Packet"
99

10-
1110
from .Device import Device # noqa
1211
from .Facility import Facility # noqa
1312
from .OperatingSystem import OperatingSystem # noqa

0 commit comments

Comments
 (0)