FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-gitlab/tests/functional/api/test_snippets.py at main · quadrantica/python-gitlab · GitHub
quadrantica
python-gitlab
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-gitlab
/
tests
/
functional
/
api
/
test_snippets.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (54 loc) · 2.07 KB
Breadcrumbs
python-gitlab
/
tests
/
functional
/
api
/
test_snippets.py
Copy path
File metadata and controls
74 lines (54 loc) · 2.07 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
import
gitlab
def
test_snippets
(
gl
):
snippets
=
gl
.
snippets
.
list
(
get_all
=
True
)
assert
not
snippets
snippet
=
gl
.
snippets
.
create
(
{
"title"
:
"snippet1"
,
"files"
: [{
"file_path"
:
"snippet1.py"
,
"content"
:
"import gitlab"
}],
}
)
snippet
=
gl
.
snippets
.
get
(
snippet
.
id
)
snippet
.
title
=
"updated_title"
snippet
.
save
()
snippet
=
gl
.
snippets
.
get
(
snippet
.
id
)
assert
snippet
.
title
==
"updated_title"
content
=
snippet
.
content
()
assert
content
.
decode
()
==
"import gitlab"
assert
snippet
.
user_agent_detail
()[
"user_agent"
]
snippet
.
delete
()
assert
snippet
not
in
gl
.
snippets
.
list
(
get_all
=
True
)
def
test_project_snippets
(
project
):
project
.
snippets_enabled
=
True
project
.
save
()
snippet
=
project
.
snippets
.
create
(
{
"title"
:
"snip1"
,
"files"
: [{
"file_path"
:
"foo.py"
,
"content"
:
"initial content"
}],
"visibility"
:
gitlab
.
const
.
VISIBILITY_PRIVATE
,
}
)
assert
snippet
.
user_agent_detail
()[
"user_agent"
]
def
test_project_snippet_discussion
(
project
):
snippet
=
project
.
snippets
.
list
()[
0
]
discussion
=
snippet
.
discussions
.
create
({
"body"
:
"Discussion body"
})
assert
discussion
in
snippet
.
discussions
.
list
()
note
=
discussion
.
notes
.
create
({
"body"
:
"first note"
})
note_from_get
=
discussion
.
notes
.
get
(
note
.
id
)
note_from_get
.
body
=
"updated body"
note_from_get
.
save
()
discussion
=
snippet
.
discussions
.
get
(
discussion
.
id
)
assert
discussion
.
attributes
[
"notes"
][
-
1
][
"body"
]
==
"updated body"
note_from_get
.
delete
()
discussion
=
snippet
.
discussions
.
get
(
discussion
.
id
)
assert
len
(
discussion
.
attributes
[
"notes"
])
==
1
def
test_project_snippet_file
(
project
):
snippet
=
project
.
snippets
.
list
()[
0
]
snippet
.
file_name
=
"bar.py"
snippet
.
save
()
snippet
=
project
.
snippets
.
get
(
snippet
.
id
)
assert
snippet
.
content
().
decode
()
==
"initial content"
assert
snippet
.
file_name
==
"bar.py"
assert
snippet
in
project
.
snippets
.
list
()
snippet
.
delete
()
assert
snippet
not
in
project
.
snippets
.
list
()
Back
|
FazBrowse Home
|
New Git URL