File: test_wikis.py

package info (click to toggle)
python-gitlab 1%3A4.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,048 kB
  • sloc: python: 24,168; makefile: 171; ruby: 27; javascript: 3
file content (62 lines) | stat: -rw-r--r-- 1,728 bytes parent folder | download
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})"