forked from python-gitlab/python-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_wikis.py
More file actions
62 lines (46 loc) · 1.69 KB
/
test_wikis.py
File metadata and controls
62 lines (46 loc) · 1.69 KB
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
"""
GitLab API:
https://docs.gitlab.com/ee/api/wikis.html
"""
def test_project_wikis(project):
page = project.wikis.create({"title": "title/subtitle", "content": "test content"})
page.content = "update content"
page.title = "subtitle"
page.save()
page.delete()
def test_project_wiki_file_upload(project):
page = project.wikis.create(
{"title": "title/subtitle", "content": "test page content"}
)
filename = "test.txt"
file_contents = "testing contents"
uploaded_file = page.upload(filename, file_contents)
link = uploaded_file["link"]
file_name = uploaded_file["file_name"]
file_path = uploaded_file["file_path"]
assert file_name == filename
assert file_path.startswith("uploads/")
assert file_path.endswith(f"/{filename}")
assert link["url"] == file_path
assert link["markdown"] == f"[{file_name}]({file_path})"
def test_group_wikis(group):
page = group.wikis.create({"title": "title/subtitle", "content": "test content"})
page.content = "update content"
page.title = "subtitle"
page.save()
page.delete()
def test_group_wiki_file_upload(group):
page = group.wikis.create(
{"title": "title/subtitle", "content": "test page content"}
)
filename = "test.txt"
file_contents = "testing contents"
uploaded_file = page.upload(filename, file_contents)
link = uploaded_file["link"]
file_name = uploaded_file["file_name"]
file_path = uploaded_file["file_path"]
assert file_name == filename
assert file_path.startswith("uploads/")
assert file_path.endswith(f"/{filename}")
assert link["url"] == file_path
assert link["markdown"] == f"[{file_name}]({file_path})"