forked from underwoo/gh_sync
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_gitlab.py
More file actions
102 lines (86 loc) · 3.66 KB
/
test_gitlab.py
File metadata and controls
102 lines (86 loc) · 3.66 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
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
import tomllib
import pathlib
import os
import gitlab
configFile = os.path.join(pathlib.Path.home(), ".ghsyncrc")
with open(configFile, "rb") as f:
config = tomllib.load(f)
gl_token = config["gitlab-token"]
gl_url = config["gitlab-url"]
gl = gitlab.Gitlab(gl_url, gl_token)
test_group = "gitlabUtilities"
print(f"Find group \"{test_group}\" by name. Print some information about the group")
group = gl.findGroup(test_group)
print(f"Group ID: {group.id}")
print(f"Group Name: {group.name}")
print(f"Group Path: {group.path}")
test_project = "gh_sync"
print(f"Find project \"{test_project}\" in group \"{test_group}\", both by name.",
"Print information about the project")
project = gl.findProject(test_project, test_group)
print(f"Project ID: {project.id}")
print(f"Project Wiki: {project.wiki_enabled}")
print(f"Project Name: {project.name}")
print(f"Project Path: {project.path}")
print(f"Project Web URL: {project.web_url}")
print(f"Project Wiki URL: {project.wiki_url}")
print(f"Project Wiki Path: {project.wiki_path}")
print(f"Find project \"{test_project}\" in group \"{test_group}\", project by name, group by object",
"Print information about the project")
project = gl.findProject('gh_sync', group)
print(f"Project ID: {project.id}")
print(f"Project Wiki: {project.wiki_enabled}")
print(f"Project Name: {project.name}")
print(f"Project Path: {project.path}")
print(f"Project Web URL: {project.web_url}")
print(f"Project Wiki URL: {project.wiki_url}")
print(f"Project Wiki Path: {project.wiki_path}")
print("Look for an group that doesn't exist",
"The group ID should be \"-1\"")
group = gl.findGroup('noGroup')
print(f"Group ID: {group.id}")
# Everything below was tested, but as I was testing against a
# production server, I have left this as commented out, for now.
# test_project = "test_project"
# test_group = "test"
# print(f"Create \"{test_project}\" in group \"{test_group}\".",
# "Print information about the new project")
# project = gl.createProject(test_project, test_group)
# print(f"Project ID: {project.id}")
# print(f"Project Wiki: {project.wiki_enabled}")
# print(f"Project Name: {project.name}")
# print(f"Project Path: {project.path}")
# print(f"Project Web URL: {project.web_url}")
# print(f"Project Wiki URL: {project.wiki_url}")
# print(f"Project Wiki Path: {project.wiki_path}")
# test_project = "test_project2"
# test_group = "test"
# group = gl.findGroup(test_group)
# print(f"Create project \{test_project}\" in group \"{test_group}\".",
# "Print information about the new project.")
# project = gl.createProject('test_project2', group, wiki_enabled=True)
# print(f"Project ID: {project.id}")
# print(f"Project Wiki: {project.wiki_enabled}")
# print(f"Project Name: {project.name}")
# print(f"Project Path: {project.path}")
# print(f"Project Web URL: {project.web_url}")
# print(f"Project Wiki URL: {project.wiki_url}")
# print(f"Project Wiki Path: {project.wiki_path}")
# test_project = "test_project"
# test_group = "testGroup"
# print(f"Create project \"{test_project}\" in new group \"{test_group}\".",
# "Print information about the new project.")
# project = gl.createProject(test_project, test_group)
# print(f"Project ID: {project.id}")
# print(f"Project Wiki: {project.wiki_enabled}")
# print(f"Project Name: {project.name}")
# print(f"Project Path: {project.path}")
# print(f"Project Web URL: {project.web_url}")
# print(f"Project Wiki URL: {project.wiki_url}")
# print(f"Project Wiki Path: {project.wiki_path}")
#TODO test what import_url does
# print("Attempt to create a new group \"testGroup\"")
# group = gl.createGroup('testGroup')
# print(f"Group ID: {group.id}")
# print(f"Group Name: {group.name}")
# print(f"Group Path: {group.path}")