Skip to content

Commit 8e36441

Browse files
authored
test: modernize primary-ip tests (#644)
Implement the latest testing patterns for the primary ips tests
1 parent 1262feb commit 8e36441

File tree

2 files changed

+248
-374
lines changed

2 files changed

+248
-374
lines changed

tests/unit/primary_ips/conftest.py

Lines changed: 41 additions & 237 deletions
Original file line numberDiff line numberDiff line change
@@ -4,252 +4,56 @@
44

55

66
@pytest.fixture()
7-
def primary_ip_response():
7+
def primary_ip1():
88
return {
9-
"primary_ip": {
10-
"assignee_id": 17,
11-
"assignee_type": "server",
12-
"auto_delete": True,
13-
"blocked": False,
14-
"created": "2016-01-30T23:55:00+00:00",
15-
"datacenter": {
16-
"description": "Falkenstein DC Park 8",
17-
"id": 42,
18-
"location": {
19-
"city": "Falkenstein",
20-
"country": "DE",
21-
"description": "Falkenstein DC Park 1",
22-
"id": 1,
23-
"latitude": 50.47612,
24-
"longitude": 12.370071,
25-
"name": "fsn1",
26-
"network_zone": "eu-central",
27-
},
28-
"name": "fsn1-dc8",
29-
"server_types": {
30-
"available": [1, 2, 3],
31-
"available_for_migration": [1, 2, 3],
32-
"supported": [1, 2, 3],
33-
},
34-
},
35-
"dns_ptr": [{"dns_ptr": "server.example.com", "ip": "131.232.99.1"}],
36-
"id": 42,
37-
"ip": "131.232.99.1",
38-
"labels": {},
39-
"name": "my-resource",
40-
"protection": {"delete": False},
41-
"type": "ipv4",
42-
}
43-
}
44-
45-
46-
@pytest.fixture()
47-
def one_primary_ips_response():
48-
return {
49-
"meta": {
50-
"pagination": {
51-
"last_page": 4,
52-
"next_page": 4,
53-
"page": 3,
54-
"per_page": 25,
55-
"previous_page": 2,
56-
"total_entries": 100,
57-
}
9+
"id": 42,
10+
"name": "primary-ip1",
11+
"type": "ipv4",
12+
"ip": "131.232.99.1",
13+
"assignee_id": 17,
14+
"assignee_type": "server",
15+
"auto_delete": True,
16+
"blocked": False,
17+
"datacenter": {
18+
"id": 4,
19+
"name": "fsn1-dc14",
5820
},
59-
"primary_ips": [
60-
{
61-
"assignee_id": 17,
62-
"assignee_type": "server",
63-
"auto_delete": True,
64-
"blocked": False,
65-
"created": "2016-01-30T23:55:00+00:00",
66-
"datacenter": {
67-
"description": "Falkenstein DC Park 8",
68-
"id": 42,
69-
"location": {
70-
"city": "Falkenstein",
71-
"country": "DE",
72-
"description": "Falkenstein DC Park 1",
73-
"id": 1,
74-
"latitude": 50.47612,
75-
"longitude": 12.370071,
76-
"name": "fsn1",
77-
"network_zone": "eu-central",
78-
},
79-
"name": "fsn1-dc8",
80-
"server_types": {
81-
"available": [1, 2, 3],
82-
"available_for_migration": [1, 2, 3],
83-
"supported": [1, 2, 3],
84-
},
85-
},
86-
"dns_ptr": [{"dns_ptr": "server.example.com", "ip": "131.232.99.1"}],
87-
"id": 42,
88-
"ip": "131.232.99.1",
89-
"labels": {},
90-
"name": "my-resource",
91-
"protection": {"delete": False},
92-
"type": "ipv4",
93-
}
94-
],
95-
}
96-
97-
98-
@pytest.fixture()
99-
def all_primary_ips_response():
100-
return {
101-
"meta": {
102-
"pagination": {
103-
"last_page": 1,
104-
"next_page": None,
105-
"page": 1,
106-
"per_page": 25,
107-
"previous_page": None,
108-
"total_entries": 1,
109-
}
21+
"location": {
22+
"id": 1,
23+
"name": "fsn1",
11024
},
111-
"primary_ips": [
112-
{
113-
"assignee_id": 17,
114-
"assignee_type": "server",
115-
"auto_delete": True,
116-
"blocked": False,
117-
"created": "2016-01-30T23:55:00+00:00",
118-
"datacenter": {
119-
"description": "Falkenstein DC Park 8",
120-
"id": 42,
121-
"location": {
122-
"city": "Falkenstein",
123-
"country": "DE",
124-
"description": "Falkenstein DC Park 1",
125-
"id": 1,
126-
"latitude": 50.47612,
127-
"longitude": 12.370071,
128-
"name": "fsn1",
129-
"network_zone": "eu-central",
130-
},
131-
"name": "fsn1-dc8",
132-
"server_types": {
133-
"available": [1, 2, 3],
134-
"available_for_migration": [1, 2, 3],
135-
"supported": [1, 2, 3],
136-
},
137-
},
138-
"dns_ptr": [{"dns_ptr": "server.example.com", "ip": "131.232.99.1"}],
139-
"id": 42,
140-
"ip": "131.232.99.1",
141-
"labels": {},
142-
"name": "my-resource",
143-
"protection": {"delete": False},
144-
"type": "ipv4",
145-
}
25+
"dns_ptr": [
26+
{"dns_ptr": "server.example.com", "ip": "131.232.99.1"},
14627
],
28+
"labels": {"key": "value"},
29+
"protection": {"delete": False},
30+
"created": "2016-01-30T23:55:00Z",
14731
}
14832

14933

15034
@pytest.fixture()
151-
def primary_ip_create_response():
35+
def primary_ip2():
15236
return {
153-
"action": {
154-
"command": "create_primary_ip",
155-
"error": {"code": "action_failed", "message": "Action failed"},
156-
"finished": None,
157-
"id": 13,
158-
"progress": 0,
159-
"resources": [{"id": 17, "type": "server"}],
160-
"started": "2016-01-30T23:50:00+00:00",
161-
"status": "running",
37+
"id": 52,
38+
"name": "primary-ip2",
39+
"type": "ipv4",
40+
"ip": "131.232.99.2",
41+
"assignee_id": None,
42+
"assignee_type": "server",
43+
"auto_delete": True,
44+
"blocked": False,
45+
"datacenter": {
46+
"id": 4,
47+
"name": "fsn1-dc14",
16248
},
163-
"primary_ip": {
164-
"assignee_id": 17,
165-
"assignee_type": "server",
166-
"auto_delete": True,
167-
"blocked": False,
168-
"created": "2016-01-30T23:50:00+00:00",
169-
"datacenter": {
170-
"description": "Falkenstein DC Park 8",
171-
"id": 42,
172-
"location": {
173-
"city": "Falkenstein",
174-
"country": "DE",
175-
"description": "Falkenstein DC Park 1",
176-
"id": 1,
177-
"latitude": 50.47612,
178-
"longitude": 12.370071,
179-
"name": "fsn1",
180-
"network_zone": "eu-central",
181-
"server_types": {
182-
"available": [1, 2, 3],
183-
"available_for_migration": [1, 2, 3],
184-
"supported": [1, 2, 3],
185-
},
186-
},
187-
"name": "fsn1-dc8",
188-
},
189-
"dns_ptr": [{"dns_ptr": "server.example.com", "ip": "2001:db8::1"}],
190-
"id": 42,
191-
"ip": "131.232.99.1",
192-
"labels": {"labelkey": "value"},
193-
"name": "my-ip",
194-
"protection": {"delete": False},
195-
"type": "ipv4",
49+
"location": {
50+
"id": 1,
51+
"name": "fsn1",
19652
},
197-
}
198-
199-
200-
@pytest.fixture()
201-
def response_update_primary_ip():
202-
return {
203-
"primary_ip": {
204-
"assignee_id": 17,
205-
"assignee_type": "server",
206-
"auto_delete": True,
207-
"blocked": False,
208-
"created": "2016-01-30T23:55:00+00:00",
209-
"datacenter": {
210-
"description": "Falkenstein DC Park 8",
211-
"id": 42,
212-
"location": {
213-
"city": "Falkenstein",
214-
"country": "DE",
215-
"description": "Falkenstein DC Park 1",
216-
"id": 1,
217-
"latitude": 50.47612,
218-
"longitude": 12.370071,
219-
"name": "fsn1",
220-
"network_zone": "eu-central",
221-
},
222-
"name": "fsn1-dc8",
223-
"server_types": {
224-
"available": [1, 2, 3],
225-
"available_for_migration": [1, 2, 3],
226-
"supported": [1, 2, 3],
227-
},
228-
},
229-
"dns_ptr": [{"dns_ptr": "server.example.com", "ip": "131.232.99.1"}],
230-
"id": 42,
231-
"ip": "131.232.99.1",
232-
"labels": {},
233-
"name": "my-resource",
234-
"protection": {"delete": False},
235-
"type": "ipv4",
236-
}
237-
}
238-
239-
240-
@pytest.fixture()
241-
def response_get_actions():
242-
return {
243-
"actions": [
244-
{
245-
"id": 13,
246-
"command": "assign_primary_ip",
247-
"status": "success",
248-
"progress": 100,
249-
"started": "2016-01-30T23:55:00+00:00",
250-
"finished": "2016-01-30T23:56:00+00:00",
251-
"resources": [{"id": 42, "type": "server"}],
252-
"error": {"code": "action_failed", "message": "Action failed"},
253-
}
254-
]
53+
"dns_ptr": [
54+
{"dns_ptr": "server.example.com", "ip": "131.232.99.1"},
55+
],
56+
"labels": {"key": "value"},
57+
"protection": {"delete": False},
58+
"created": "2016-01-30T23:55:00Z",
25559
}

0 commit comments

Comments
 (0)