FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-gitlab/tests/unit/objects/test_snippets.py at v8.6.0 · python-gitlab/python-gitlab · GitHub
python-gitlab
python-gitlab
Repository navigation
Code
Issues
16
(16)
Pull requests
15
(15)
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-gitlab
/
tests
/
unit
/
objects
/
test_snippets.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
84 lines (70 loc) · 2.38 KB
Breadcrumbs
python-gitlab
/
tests
/
unit
/
objects
/
test_snippets.py
Copy path
File metadata and controls
84 lines (70 loc) · 2.38 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
"""
GitLab API: https://docs.gitlab.com/ce/api/project_snippets.html
https://docs.gitlab.com/ee/api/snippets.html (todo)
"""
import
pytest
import
responses
title
=
"Example Snippet Title"
visibility
=
"private"
new_title
=
"new-title"
@
pytest
.
fixture
def
resp_snippet
():
content
=
{
"title"
:
title
,
"description"
:
"More verbose snippet description"
,
"file_name"
:
"example.txt"
,
"content"
:
"source code with multiple lines"
,
"visibility"
:
visibility
,
}
with
responses
.
RequestsMock
(
assert_all_requests_are_fired
=
False
)
as
rsps
:
rsps
.
add
(
method
=
responses
.
GET
,
url
=
"http://localhost/api/v4/projects/1/snippets"
,
json
=
[
content
],
content_type
=
"application/json"
,
status
=
200
,
)
rsps
.
add
(
method
=
responses
.
GET
,
url
=
"http://localhost/api/v4/projects/1/snippets/1"
,
json
=
content
,
content_type
=
"application/json"
,
status
=
200
,
)
rsps
.
add
(
method
=
responses
.
POST
,
url
=
"http://localhost/api/v4/projects/1/snippets"
,
json
=
content
,
content_type
=
"application/json"
,
status
=
200
,
)
updated_content
=
dict
(
content
)
updated_content
[
"title"
]
=
new_title
updated_content
[
"visibility"
]
=
visibility
rsps
.
add
(
method
=
responses
.
PUT
,
url
=
"http://localhost/api/v4/projects/1/snippets"
,
json
=
updated_content
,
content_type
=
"application/json"
,
status
=
200
,
)
yield
rsps
def
test_list_project_snippets
(
project
,
resp_snippet
):
snippets
=
project
.
snippets
.
list
()
assert
len
(
snippets
)
==
1
assert
snippets
[
0
].
title
==
title
assert
snippets
[
0
].
visibility
==
visibility
def
test_get_project_snippet
(
project
,
resp_snippet
):
snippet
=
project
.
snippets
.
get
(
1
)
assert
snippet
.
title
==
title
assert
snippet
.
visibility
==
visibility
def
test_create_update_project_snippets
(
project
,
resp_snippet
):
snippet
=
project
.
snippets
.
create
(
{
"title"
:
title
,
"file_name"
:
title
,
"content"
:
title
,
"visibility"
:
visibility
}
)
assert
snippet
.
title
==
title
assert
snippet
.
visibility
==
visibility
snippet
.
title
=
new_title
snippet
.
save
()
assert
snippet
.
title
==
new_title
assert
snippet
.
visibility
==
visibility
Back
|
FazBrowse Home
|
New Git URL