diff options
-rw-r--r-- | gitlab/__init__.py | 2 | ||||
-rw-r--r-- | gitlab/objects.py | 5 | ||||
-rw-r--r-- | tools/python_test.py | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index a13c951..d8ee5bf 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -454,7 +454,7 @@ class Gitlab(object): raise GitlabDeleteError('Missing attribute(s): %s' % ", ".join(missing)) - obj_id = params[obj.idAttr] + obj_id = params[obj.idAttr] if obj._id_in_delete_url else None url = self._construct_url(id_=obj_id, obj=obj, parameters=params) headers = self._create_headers() diff --git a/gitlab/objects.py b/gitlab/objects.py index 6e15c3a..5ae1fb3 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -177,11 +177,12 @@ class GitlabObject(object): # Some objects (e.g. merge requests) have different urls for singular and # plural _urlPlural = None + _id_in_delete_url = True _returnClass = None _constructorTypes = None + #: Whether _get_list_or_object should return list or object when id is None getListWhenNoId = True - #: Tells if GitLab-api allows retrieving single objects. canGet = True #: Tells if GitLab-api allows listing of objects. @@ -897,6 +898,8 @@ class ProjectMilestoneManager(BaseManager): class ProjectLabel(GitlabObject): _url = '/projects/%(project_id)s/labels' + _id_in_delete_url = False + canGet = 'from_list' requiredUrlAttrs = ['project_id'] idAttr = 'name' requiredDeleteAttrs = ['name'] diff --git a/tools/python_test.py b/tools/python_test.py index 2231132..0d3b9f2 100644 --- a/tools/python_test.py +++ b/tools/python_test.py @@ -115,12 +115,12 @@ assert(readme.decode() == 'Initial content') # labels label1 = admin_project.labels.create({'name': 'label1', 'color': '#778899'}) +label1 = admin_project.labels.get('label1') assert(len(admin_project.labels.list()) == 1) label1.new_name = 'label1updated' label1.save() assert(label1.name == 'label1updated') -# FIXME(gpocentek): broken -# label1.delete() +label1.delete() # milestones m1 = admin_project.milestones.create({'title': 'milestone1'}) |