def test_get_issue_milestone(self): issue = self.issue milestone = self.milestone user = User('testuser') ims1 = IssueMilestone.create_by_issue(issue, milestone, user) ims = IssueMilestone.get_by_issue(issue) self.assertEqual(ims.id, ims1.id) self.assertEqual(ims.issue_id, ims1.issue_id) self.assertEqual(ims.milestone_id, ims1.milestone_id) self.assertEqual(ims.creator_id, ims1.creator_id)
def add_milestone(self, user, name=None, milestone_id=None): from vilya.models.milestone import Milestone target = self.target if name: ms = Milestone.get_by_project(target, name=name) if not ms: ms = Milestone.create_by_project(self.target, name, user) elif milestone_id: ms = Milestone.get_by(milestone_id) else: return None ims = IssueMilestone.get_by_issue(self) if ims: ims.milestone_id = ms.id ims.save() else: ims = IssueMilestone.create_by_issue(self, ms, user)
def remove_milestone(self): ims = IssueMilestone.get_by_issue(self) if ims: ims.delete()