Skip to content

Commit e9b8c76

Browse files
authored
refactor: modernize images client tests (#681)
1 parent 85b401c commit e9b8c76

2 files changed

Lines changed: 170 additions & 248 deletions

File tree

tests/unit/images/conftest.py

Lines changed: 47 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -4,141 +4,57 @@
44

55

66
@pytest.fixture()
7-
def image_response():
7+
def image1():
88
return {
9-
"image": {
10-
"id": 4711,
11-
"type": "snapshot",
12-
"status": "available",
13-
"name": "ubuntu-20.04",
14-
"description": "Ubuntu 20.04 Standard 64 bit",
15-
"image_size": 2.3,
16-
"disk_size": 10,
17-
"created": "2016-01-30T23:50+00:00",
18-
"created_from": {"id": 1, "name": "Server"},
19-
"bound_to": 1,
20-
"os_flavor": "ubuntu",
21-
"os_version": "16.04",
22-
"architecture": "x86",
23-
"rapid_deploy": False,
24-
"protection": {"delete": False},
25-
"deprecated": "2018-02-28T00:00:00+00:00",
26-
"labels": {},
27-
}
9+
"id": 45557056,
10+
"name": "debian-11",
11+
"architecture": "x86",
12+
"bound_to": None,
13+
"created": "2021-08-16T11:12:01Z",
14+
"created_from": None,
15+
"deleted": None,
16+
"deprecated": "2026-08-31T06:21:44Z",
17+
"description": "Debian 11",
18+
"disk_size": 5,
19+
"image_size": None,
20+
"labels": {},
21+
"os_flavor": "debian",
22+
"os_version": "11",
23+
"protection": {
24+
"delete": False,
25+
},
26+
"rapid_deploy": True,
27+
"status": "available",
28+
"type": "system",
2829
}
2930

3031

3132
@pytest.fixture()
32-
def two_images_response():
33+
def image2():
3334
return {
34-
"images": [
35-
{
36-
"id": 4711,
37-
"type": "snapshot",
38-
"status": "available",
39-
"name": "ubuntu-20.04",
40-
"description": "Ubuntu 20.04 Standard 64 bit",
41-
"image_size": 2.3,
42-
"disk_size": 10,
43-
"created": "2016-01-30T23:50+00:00",
44-
"created_from": {"id": 1, "name": "Server"},
45-
"bound_to": None,
46-
"os_flavor": "ubuntu",
47-
"os_version": "16.04",
48-
"architecture": "x86",
49-
"rapid_deploy": False,
50-
"protection": {"delete": False},
51-
"deprecated": "2018-02-28T00:00:00+00:00",
52-
"labels": {},
53-
},
54-
{
55-
"id": 4712,
56-
"type": "system",
57-
"status": "available",
58-
"name": "ubuntu-18.10",
59-
"description": "Ubuntu 18.10 Standard 64 bit",
60-
"image_size": 2.3,
61-
"disk_size": 10,
62-
"created": "2016-01-30T23:50+00:00",
63-
"created_from": {"id": 1, "name": "Server"},
64-
"bound_to": None,
65-
"os_flavor": "ubuntu",
66-
"os_version": "16.04",
67-
"architecture": "x86",
68-
"rapid_deploy": False,
69-
"protection": {"delete": False},
70-
"deprecated": "2018-02-28T00:00:00+00:00",
71-
"labels": {},
72-
},
73-
]
74-
}
75-
76-
77-
@pytest.fixture()
78-
def one_images_response():
79-
return {
80-
"images": [
81-
{
82-
"id": 4711,
83-
"type": "snapshot",
84-
"status": "available",
85-
"name": "ubuntu-20.04",
86-
"description": "Ubuntu 20.04 Standard 64 bit",
87-
"image_size": 2.3,
88-
"disk_size": 10,
89-
"created": "2016-01-30T23:50+00:00",
90-
"created_from": {"id": 1, "name": "Server"},
91-
"bound_to": None,
92-
"os_flavor": "ubuntu",
93-
"os_version": "16.04",
94-
"architecture": "x86",
95-
"rapid_deploy": False,
96-
"protection": {"delete": False},
97-
"deprecated": "2018-02-28T00:00:00+00:00",
98-
"labels": {},
99-
}
100-
]
101-
}
102-
103-
104-
@pytest.fixture()
105-
def response_update_image():
106-
return {
107-
"image": {
108-
"id": 4711,
109-
"type": "snapshot",
110-
"status": "available",
111-
"name": None,
112-
"description": "My new Image description",
113-
"image_size": 2.3,
114-
"disk_size": 10,
115-
"created": "2016-01-30T23:50+00:00",
116-
"created_from": {"id": 1, "name": "Server"},
117-
"bound_to": None,
118-
"os_flavor": "ubuntu",
119-
"os_version": "16.04",
120-
"architecture": "arm",
121-
"rapid_deploy": False,
122-
"protection": {"delete": False},
123-
"deprecated": "2018-02-28T00:00:00+00:00",
124-
"labels": {},
125-
}
126-
}
127-
128-
129-
@pytest.fixture()
130-
def response_get_actions():
131-
return {
132-
"actions": [
133-
{
134-
"id": 13,
135-
"command": "change_protection",
136-
"status": "success",
137-
"progress": 100,
138-
"started": "2016-01-30T23:55:00+00:00",
139-
"finished": "2016-01-30T23:56:00+00:00",
140-
"resources": [{"id": 42, "type": "image"}],
141-
"error": {"code": "action_failed", "message": "Action failed"},
142-
}
143-
]
35+
"id": 429564329,
36+
"name": None,
37+
"architecture": "x86",
38+
"bound_to": 159969127,
39+
"created": "2026-09-08T13:44:08Z",
40+
"created_from": {
41+
"id": 159969127,
42+
"name": "server1",
43+
},
44+
"deleted": None,
45+
"deprecated": None,
46+
"description": "snapshot 2026-09-08T13:44:08Z",
47+
"disk_size": 80,
48+
"image_size": 0.7237785009765625,
49+
"labels": {
50+
"key": "value",
51+
},
52+
"os_flavor": "debian",
53+
"os_version": "13",
54+
"protection": {
55+
"delete": True,
56+
},
57+
"rapid_deploy": False,
58+
"status": "available",
59+
"type": "snapshot",
14460
}

0 commit comments

Comments
 (0)