1
# Copyright 2005-2011 Canonical Ltd. All rights reserved.
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU Affero General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Affero General Public License for more details.
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
from bzrlib.branch import Branch
22
LPLIB_ROOT="https://api.edge.launchpad.net/beta"
26
"""Convenience class to untar the sample data branch."""
28
# XXX: fix this hardcoded path
29
TEST_DATA = "tests/sample_data/branch_data.tar.bz2"
32
tar_file = tarfile.open(self.TEST_DATA)
33
tmp_dir = tempfile.mkdtemp()
34
tar_file.extractall(tmp_dir)
36
self.branch_name = 'devel'
37
self.branch_path = os.path.join(tmp_dir, self.branch_name)
40
def open_branch(self):
41
self.branch = Branch.open(self.branch_path)
47
def __init__(self, bug_id):
52
self.self_link = "%s/bugs/%s" % (LPLIB_ROOT, bug_id)
54
def addBugTask(self, bug_id, target_name, status):
55
bug_task = FakeBugTask(bug_id, target_name, status)
57
bug_task.addTarget(target_name)
58
self.bug_tasks.append(bug_task)
60
def newMessage(self, subject, content):
61
self.messages.append((subject, content))
69
def __init__(self, bug_id, target_name, status=u"Fix Committed"):
72
self.bug_target_name = target_name
78
self.self_link = "%s/%s/+bug/%s" % (LPLIB_ROOT, target_name, bug_id)
80
def addTarget(self, target_name):
81
self.target = FakeTarget(target_name)
83
def transitionToAssignee(self, assignee):
84
self.assignee = assignee
86
def transitionToMilestone(self, milestone):
87
self.milestone = milestone
92
def __init__(self, target_name):
93
self.self_link = "%s/%s" % (LPLIB_ROOT, target_name)
101
def getByEmail(self, email):
103
person = self._people[email]
111
def __init__(self, name, display_name, email):
113
self.display_name = display_name
114
self.preferred_email = email
115
self.self_link = "%s/~%s" % (LPLIB_ROOT, name)
123
def getByUrl(self, url):
125
branch = self._branches[url]
133
def __init__(self, branch_nick, owner, project, linked_bugs):
135
self.url = "lp:%s/%s/%s" % (owner.name, project, branch_nick)
136
self.project = project
137
self.linked_bugs = linked_bugs
139
self.properties["branch-nick"] = branch_nick
144
def __init__(self, milestone_name, target, active=True):
145
self.name = milestone_name
147
self.is_active = active
152
def __init__(self, project_name, milestone=None):
153
self.name = project_name
154
self.milestone = milestone
155
self.self_link = "%s/%s" % (LPLIB_ROOT, project_name)
157
def getMilestone(self, name):
158
return FakeMilestone(name, self, True)
164
self.people = FakePeople()
166
self.branches = FakeBranches()
169
def createBugWithBugTask(self, bug_id, target_name, status):
170
fake_bug = FakeBug(bug_id)
171
fake_bug.addBugTask(bug_id, target_name, status)
172
self.bugs[bug_id] = fake_bug
175
def createPerson(self, name, display_name, email):
176
fake_person = FakePerson(name, display_name, email)
177
self.people._people[email] = fake_person
180
def createBranch(self, branch_nick, owner, project, linked_bugs):
181
fake_branch = FakeBranch(branch_nick, owner, project, linked_bugs)
182
self.branches._branches[fake_branch.url] = fake_branch
185
def createProject(self, name):
186
fake_project = FakeProject(name)
187
self.projects[name] = fake_project