FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-gitlab/tests/unit/objects/test_deployments.py at main · stdexception/python-gitlab · GitHub
stdexception
python-gitlab
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-gitlab
/
tests
/
unit
/
objects
/
test_deployments.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
180 lines (159 loc) · 5.31 KB
Breadcrumbs
python-gitlab
/
tests
/
unit
/
objects
/
test_deployments.py
Copy path
File metadata and controls
180 lines (159 loc) · 5.31 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
"""
GitLab API: https://docs.gitlab.com/ce/api/deployments.html
"""
import
pytest
import
responses
@
pytest
.
fixture
def
resp_deployment_get
():
with
responses
.
RequestsMock
()
as
rsps
:
rsps
.
add
(
method
=
responses
.
GET
,
url
=
"http://localhost/api/v4/projects/1/deployments/42"
,
json
=
response_get_content
,
content_type
=
"application/json"
,
status
=
200
,
)
yield
rsps
@
pytest
.
fixture
def
deployment
(
project
):
return
project
.
deployments
.
get
(
42
,
lazy
=
True
)
@
pytest
.
fixture
def
resp_deployment_create
():
content
=
{
"id"
:
42
,
"status"
:
"success"
,
"ref"
:
"main"
}
with
responses
.
RequestsMock
()
as
rsps
:
rsps
.
add
(
method
=
responses
.
POST
,
url
=
"http://localhost/api/v4/projects/1/deployments"
,
json
=
content
,
content_type
=
"application/json"
,
status
=
200
,
)
updated_content
=
dict
(
content
)
updated_content
[
"status"
]
=
"failed"
rsps
.
add
(
method
=
responses
.
PUT
,
url
=
"http://localhost/api/v4/projects/1/deployments/42"
,
json
=
updated_content
,
content_type
=
"application/json"
,
status
=
200
,
)
yield
rsps
@
pytest
.
fixture
def
resp_deployment_approval
():
content
=
{
"user"
: {
"id"
:
100
,
"username"
:
"security-user-1"
,
"name"
:
"security user-1"
,
"state"
:
"active"
,
"avatar_url"
:
"https://www.gravatar.com/avatar/e130fcd3a1681f41a3de69d10841afa9?s=80&d=identicon"
,
"web_url"
:
"http://localhost:3000/security-user-1"
,
},
"status"
:
"approved"
,
"created_at"
:
"2022-02-24T20:22:30.097Z"
,
"comment"
:
"Looks good to me"
,
}
with
responses
.
RequestsMock
()
as
rsps
:
rsps
.
add
(
method
=
responses
.
POST
,
url
=
"http://localhost/api/v4/projects/1/deployments/42/approval"
,
json
=
content
,
content_type
=
"application/json"
,
status
=
200
,
)
yield
rsps
def
test_deployment_get
(
project
,
resp_deployment_get
):
deployment
=
project
.
deployments
.
get
(
42
)
assert
deployment
.
id
==
42
assert
deployment
.
iid
==
2
assert
deployment
.
status
==
"success"
assert
deployment
.
ref
==
"main"
def
test_deployment_create
(
project
,
resp_deployment_create
):
deployment
=
project
.
deployments
.
create
(
{
"environment"
:
"Test"
,
"sha"
:
"1agf4gs"
,
"ref"
:
"main"
,
"tag"
:
False
,
"status"
:
"created"
,
}
)
assert
deployment
.
id
==
42
assert
deployment
.
status
==
"success"
assert
deployment
.
ref
==
"main"
deployment
.
status
=
"failed"
deployment
.
save
()
assert
deployment
.
status
==
"failed"
def
test_deployment_approval
(
deployment
,
resp_deployment_approval
)
->
None
:
result
=
deployment
.
approval
(
status
=
"approved"
)
assert
result
[
"status"
]
==
"approved"
assert
result
[
"comment"
]
==
"Looks good to me"
response_get_content
=
{
"id"
:
42
,
"iid"
:
2
,
"ref"
:
"main"
,
"sha"
:
"a91957a858320c0e17f3a0eca7cfacbff50ea29a"
,
"created_at"
:
"2016-08-11T11:32:35.444Z"
,
"updated_at"
:
"2016-08-11T11:34:01.123Z"
,
"status"
:
"success"
,
"user"
: {
"name"
:
"Administrator"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
,
"web_url"
:
"http://localhost:3000/root"
,
},
"environment"
: {
"id"
:
9
,
"name"
:
"production"
,
"external_url"
:
"https://about.gitlab.com"
,
},
"deployable"
: {
"id"
:
664
,
"status"
:
"success"
,
"stage"
:
"deploy"
,
"name"
:
"deploy"
,
"ref"
:
"main"
,
"tag"
:
False
,
"coverage"
:
None
,
"created_at"
:
"2016-08-11T11:32:24.456Z"
,
"started_at"
:
None
,
"finished_at"
:
"2016-08-11T11:32:35.145Z"
,
"user"
: {
"id"
:
1
,
"name"
:
"Administrator"
,
"username"
:
"root"
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
,
"web_url"
:
"http://gitlab.dev/root"
,
"created_at"
:
"2015-12-21T13:14:24.077Z"
,
"bio"
:
None
,
"location"
:
None
,
"skype"
:
""
,
"linkedin"
:
""
,
"twitter"
:
""
,
"website_url"
:
""
,
"organization"
:
""
,
},
"commit"
: {
"id"
:
"a91957a858320c0e17f3a0eca7cfacbff50ea29a"
,
"short_id"
:
"a91957a8"
,
"title"
:
"Merge branch 'rename-readme' into 'main'
\r
"
,
"author_name"
:
"Administrator"
,
"author_email"
:
"admin@example.com"
,
"created_at"
:
"2016-08-11T13:28:26.000+02:00"
,
"message"
:
"Merge branch 'rename-readme' into 'main'
\r
\n
\r
\n
Rename README
\r
\n
\r
\n
\r
\n
\r
\n
See merge request !2"
,
},
"pipeline"
: {
"created_at"
:
"2016-08-11T07:43:52.143Z"
,
"id"
:
42
,
"ref"
:
"main"
,
"sha"
:
"a91957a858320c0e17f3a0eca7cfacbff50ea29a"
,
"status"
:
"success"
,
"updated_at"
:
"2016-08-11T07:43:52.143Z"
,
"web_url"
:
"http://gitlab.dev/root/project/pipelines/5"
,
},
"runner"
:
None
,
},
}
Back
|
FazBrowse Home
|
New Git URL