FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-gitlab/tests/unit/objects/test_draft_notes.py at main · netflash/python-gitlab · GitHub
netflash
python-gitlab
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-gitlab
/
tests
/
unit
/
objects
/
test_draft_notes.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
176 lines (143 loc) · 4.97 KB
Breadcrumbs
python-gitlab
/
tests
/
unit
/
objects
/
test_draft_notes.py
Copy path
File metadata and controls
176 lines (143 loc) · 4.97 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
"""
GitLab API: https://docs.gitlab.com/ee/api/draft_notes.html
"""
from
copy
import
deepcopy
import
pytest
import
responses
from
gitlab
.
v4
.
objects
import
ProjectMergeRequestDraftNote
draft_note_content
=
{
"id"
:
1
,
"author_id"
:
23
,
"merge_request_id"
:
1
,
"resolve_discussion"
:
False
,
"discussion_id"
:
None
,
"note"
:
"Example title"
,
"commit_id"
:
None
,
"line_code"
:
None
,
"position"
: {
"base_sha"
:
None
,
"start_sha"
:
None
,
"head_sha"
:
None
,
"old_path"
:
None
,
"new_path"
:
None
,
"position_type"
:
"text"
,
"old_line"
:
None
,
"new_line"
:
None
,
"line_range"
:
None
,
},
}
@
pytest
.
fixture
()
def
resp_list_merge_request_draft_notes
():
with
responses
.
RequestsMock
()
as
rsps
:
rsps
.
add
(
method
=
responses
.
GET
,
url
=
"http://localhost/api/v4/projects/1/merge_requests/1/draft_notes"
,
json
=
[
draft_note_content
],
content_type
=
"application/json"
,
status
=
200
,
)
yield
rsps
@
pytest
.
fixture
()
def
resp_get_merge_request_draft_note
():
with
responses
.
RequestsMock
()
as
rsps
:
rsps
.
add
(
method
=
responses
.
GET
,
url
=
"http://localhost/api/v4/projects/1/merge_requests/1/draft_notes/1"
,
json
=
draft_note_content
,
content_type
=
"application/json"
,
status
=
200
,
)
yield
rsps
@
pytest
.
fixture
()
def
resp_create_merge_request_draft_note
():
with
responses
.
RequestsMock
()
as
rsps
:
rsps
.
add
(
method
=
responses
.
POST
,
url
=
"http://localhost/api/v4/projects/1/merge_requests/1/draft_notes"
,
json
=
draft_note_content
,
content_type
=
"application/json"
,
status
=
201
,
)
yield
rsps
@
pytest
.
fixture
()
def
resp_update_merge_request_draft_note
():
updated_content
=
deepcopy
(
draft_note_content
)
updated_content
[
"note"
]
=
"New title"
with
responses
.
RequestsMock
()
as
rsps
:
rsps
.
add
(
method
=
responses
.
PUT
,
url
=
"http://localhost/api/v4/projects/1/merge_requests/1/draft_notes/1"
,
json
=
updated_content
,
content_type
=
"application/json"
,
status
=
201
,
)
yield
rsps
@
pytest
.
fixture
()
def
resp_delete_merge_request_draft_note
():
with
responses
.
RequestsMock
()
as
rsps
:
rsps
.
add
(
method
=
responses
.
DELETE
,
url
=
"http://localhost/api/v4/projects/1/merge_requests/1/draft_notes/1"
,
json
=
draft_note_content
,
content_type
=
"application/json"
,
status
=
201
,
)
yield
rsps
@
pytest
.
fixture
()
def
resp_publish_merge_request_draft_note
():
with
responses
.
RequestsMock
()
as
rsps
:
rsps
.
add
(
method
=
responses
.
PUT
,
url
=
"http://localhost/api/v4/projects/1/merge_requests/1/draft_notes/1/publish"
,
status
=
204
,
)
yield
rsps
@
pytest
.
fixture
()
def
resp_bulk_publish_merge_request_draft_notes
():
with
responses
.
RequestsMock
()
as
rsps
:
rsps
.
add
(
method
=
responses
.
POST
,
url
=
"http://localhost/api/v4/projects/1/merge_requests/1/draft_notes/bulk_publish"
,
status
=
204
,
)
yield
rsps
def
test_list_merge_requests_draft_notes
(
project_merge_request
,
resp_list_merge_request_draft_notes
):
draft_notes
=
project_merge_request
.
draft_notes
.
list
()
assert
len
(
draft_notes
)
==
1
assert
isinstance
(
draft_notes
[
0
],
ProjectMergeRequestDraftNote
)
assert
draft_notes
[
0
].
note
==
draft_note_content
[
"note"
]
def
test_get_merge_requests_draft_note
(
project_merge_request
,
resp_get_merge_request_draft_note
):
draft_note
=
project_merge_request
.
draft_notes
.
get
(
1
)
assert
isinstance
(
draft_note
,
ProjectMergeRequestDraftNote
)
assert
draft_note
.
note
==
draft_note_content
[
"note"
]
def
test_create_merge_requests_draft_note
(
project_merge_request
,
resp_create_merge_request_draft_note
):
draft_note
=
project_merge_request
.
draft_notes
.
create
({
"note"
:
"Example title"
})
assert
isinstance
(
draft_note
,
ProjectMergeRequestDraftNote
)
assert
draft_note
.
note
==
draft_note_content
[
"note"
]
def
test_update_merge_requests_draft_note
(
project_merge_request
,
resp_update_merge_request_draft_note
):
draft_note
=
project_merge_request
.
draft_notes
.
get
(
1
,
lazy
=
True
)
draft_note
.
note
=
"New title"
draft_note
.
save
()
assert
draft_note
.
note
==
"New title"
def
test_delete_merge_requests_draft_note
(
project_merge_request
,
resp_delete_merge_request_draft_note
):
draft_note
=
project_merge_request
.
draft_notes
.
get
(
1
,
lazy
=
True
)
draft_note
.
delete
()
def
test_publish_merge_requests_draft_note
(
project_merge_request
,
resp_publish_merge_request_draft_note
):
draft_note
=
project_merge_request
.
draft_notes
.
get
(
1
,
lazy
=
True
)
draft_note
.
publish
()
def
test_bulk_publish_merge_requests_draft_notes
(
project_merge_request
,
resp_bulk_publish_merge_request_draft_notes
):
project_merge_request
.
draft_notes
.
bulk_publish
()
Back
|
FazBrowse Home
|
New Git URL