Commit d953e17f authored by Alan Marchiori's avatar Alan Marchiori
Browse files

gitlab test code

parent 0b01150a
import config
import click
from utils.gitlab import GitLab
if __name__=='__main__':
with config.UserConfig() as uc:
gl = GitLab()
gl.ensure_key()
usr = gl.get_user()
print("user:", usr)
meng = gl.get_users(username='xmeng')[0]
print("Meng: ", meng)
assert meng['id'] == 9
pname ="labtool-test"
p = gl.search_for_project(pname)
list(map(gl.remove_project, [x['id'] for x in p]))
p = gl.search_for_project(pname)
assert len(p)==0, "Delete failed?"
p = gl.create_project(pname)
assert 'id' in p, "Create failed?"
# check add users
mems = gl.list_members_of_project(p['id'])
# we have one valid project here.
assert mems[0]['id'] == usr['id'], "Member should be owner!"
# add meng as maintainer
gl.add_member_to_project(p['id'], meng['id'], 40)
mems = gl.list_members_of_project(p['id'])
assert mems[0]['id'] == usr['id'], "First member should be owner!"
assert mems[1]['id'] == meng['id'], "First member should be meng!"
assert mems[0]['access_level'] >= 40, "Wrong owner access"
assert mems[1]['access_level'] == 40, "Wrong meng access"
gl.remove_project(p['id'])
p = gl.search_for_project(pname)
assert len(p)==0, "Delete failed?"
print("add/remove repo test pass.")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment