Skip to content

Commit

Permalink
Implement ProjectMilestone.issues()
Browse files Browse the repository at this point in the history
This lists the issues related to the milestone.

Add python API tests for issues.
  • Loading branch information
Gauvain Pocentek committed Jan 23, 2016
1 parent 1ecb739 commit db1fb89
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions gitlab/objects.py
Expand Up @@ -891,6 +891,19 @@ class ProjectMilestone(GitlabObject):
optionalCreateAttrs = ['description', 'due_date', 'state_event']
shortPrintAttr = 'title'

def issues(self):
url = "/projects/%s/milestones/%s/issues" % (self.project_id, self.id)
r = self.gitlab._raw_get(url)
raise_error_from_response(r, GitlabDeleteError)

l = []
for j in r.json():
o = ProjectIssue(self, j)
o._from_api = True
l.append(o)

return l


class ProjectMilestoneManager(BaseManager):
obj_cls = ProjectMilestone
Expand Down
13 changes: 13 additions & 0 deletions tools/python_test.py
Expand Up @@ -131,3 +131,16 @@
m1.save()
m1 = admin_project.milestones.get(1)
assert(m1.state == 'closed')

# issues
issue1 = admin_project.issues.create({'title': 'my issue 1',
'milestone_id': m1.id})
issue2 = admin_project.issues.create({'title': 'my issue 2'})
issue3 = admin_project.issues.create({'title': 'my issue 3'})
assert(len(admin_project.issues.list()) == 3)
issue3.state_event = 'close'
issue3.save()
assert(len(admin_project.issues.list(state='closed')) == 1)
assert(len(admin_project.issues.list(state='opened')) == 2)
assert(len(admin_project.issues.list(milestone='milestone1')) == 1)
assert(m1.issues()[0].title == 'my issue 1')

0 comments on commit db1fb89

Please sign in to comment.