mirror of
https://lab.enough.community/fedeproxy/server
synced 2025-01-14 03:33:55 +01:00
gitlab: issue create/get/delete
This commit is contained in:
parent
f54063e998
commit
eaf0e72406
@ -1,3 +1,4 @@
|
||||
import copy
|
||||
from django.conf import settings
|
||||
import logging
|
||||
import os
|
||||
@ -59,6 +60,31 @@ class GitLab(object):
|
||||
user = r.json()
|
||||
return self.is_member_of_group(group, user['username'])
|
||||
|
||||
def issue_delete(self, project_id, issue_iid):
|
||||
info = self.issue_get(project_id, issue_iid)
|
||||
if info is None:
|
||||
return False
|
||||
r = self.s.delete(f'{self.s.api}/projects/{project_id}/issues/{issue_iid}')
|
||||
r.raise_for_status()
|
||||
return True
|
||||
|
||||
def issue_get(self, project_id, issue_iid):
|
||||
r = self.s.get(f'{self.s.api}/projects/{project_id}/issues/{issue_iid}')
|
||||
if r.status_code == requests.codes.ok:
|
||||
return r.json()
|
||||
else:
|
||||
return None
|
||||
|
||||
def issue_create(self, project_id, title, **data):
|
||||
data = copy.copy(data)
|
||||
data.update({
|
||||
'title': title,
|
||||
})
|
||||
r = self.s.post(f'{self.s.api}/projects/{project_id}/issues', data=data)
|
||||
logger.debug(r.text)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
def user_delete(self, user):
|
||||
info = self.user_get(user)
|
||||
if info is None:
|
||||
|
@ -19,7 +19,7 @@ def test_project_create(gitlab):
|
||||
assert gitlab.project_get('root', 'testproject') is None
|
||||
user = 'testuser1'
|
||||
email = 'testuser1@example.com'
|
||||
u = gitlab.user_create(user, email)
|
||||
gitlab.user_create(user, email)
|
||||
p = gitlab.project_create('root', user, user, 'testproject')
|
||||
assert p['id'] == gitlab.project_create('root', user, user, 'testproject')['id']
|
||||
assert gitlab.project_delete(user, 'testproject') is True
|
||||
@ -38,6 +38,19 @@ def test_user_create(gitlab):
|
||||
assert gitlab.user_delete(user) is False
|
||||
|
||||
|
||||
@pytest.mark.gitlab
|
||||
def test_issue_create(gitlab):
|
||||
gitlab.project_delete('root', 'testproject')
|
||||
p = gitlab.project_create('root', 'root', 'root', 'testproject')
|
||||
title = 'THE TITLE'
|
||||
i = gitlab.issue_create(p['id'], title)
|
||||
assert i['id'] == gitlab.issue_get(p['id'], i['iid'])['id']
|
||||
assert gitlab.issue_delete(p['id'], i['iid']) is True
|
||||
assert gitlab.issue_get(p['id'], i['iid']) is None
|
||||
assert gitlab.issue_delete(p['id'], i['iid']) is False
|
||||
assert gitlab.project_delete('root', 'testproject') is True
|
||||
|
||||
|
||||
@pytest.mark.gitlab
|
||||
def test_project_export(gitlab, tmpdir):
|
||||
gitlab.project_delete('root', 'testproject')
|
||||
|
Loading…
Reference in New Issue
Block a user