diff options
-rw-r--r-- | becommands/close.py | 11 | ||||
-rw-r--r-- | libbe/bugdir.py | 16 | ||||
-rw-r--r-- | libbe/tests.py | 9 |
3 files changed, 30 insertions, 6 deletions
diff --git a/becommands/close.py b/becommands/close.py index 2344a90..4f50b58 100644 --- a/becommands/close.py +++ b/becommands/close.py @@ -1,6 +1,17 @@ """Close a bug""" from libbe import cmdutil def execute(args): + """ + >>> from libbe import tests + >>> import os + >>> dir = tests.simple_bug_dir() + >>> os.chdir(dir.dir) + >>> dir.get_bug("a").status + 'open' + >>> execute(("a",)) + >>> dir.get_bug("a").status + 'closed' + """ assert(len(args) == 1) bug = cmdutil.get_bug(args[0]) bug.status = "closed" diff --git a/libbe/bugdir.py b/libbe/bugdir.py index d81c616..16c1544 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -91,7 +91,7 @@ class BugDir: map_save(self.rcs, os.path.join(self.dir, "settings"), self.settings) def get_rcs(self): - if self._rcs is not None and self.rcs_name == _rcs.name: + if self._rcs is not None and self.rcs_name == self._rcs.name: return self._rcs self._rcs = rcs_by_name(self.rcs_name) return self._rcs @@ -100,7 +100,10 @@ class BugDir: def list(self): for uuid in self.list_uuids(): - yield Bug(self.bugs_path, uuid, self.rcs_name) + yield self.get_bug(uuid) + + def get_bug(self, uuid): + return Bug(self.bugs_path, uuid, self.rcs_name) def list_uuids(self): for uuid in os.listdir(self.bugs_path): @@ -108,8 +111,9 @@ class BugDir: continue yield uuid - def new_bug(self): - uuid = names.uuid() + def new_bug(self, uuid=None): + if uuid is None: + uuid = names.uuid() path = os.path.join(self.bugs_path, uuid) self.rcs.mkdir(path) bug = Bug(self.bugs_path, None, self.rcs_name) @@ -228,8 +232,8 @@ class Bug(object): def cmp_date(comm1, comm2): return cmp(comm1.date, comm2.date) -def new_bug(dir): - bug = dir.new_bug() +def new_bug(dir, uuid=None): + bug = dir.new_bug(uuid) bug.creator = names.creator() bug.severity = "minor" bug.status = "open" diff --git a/libbe/tests.py b/libbe/tests.py index b6d3083..c5b9f49 100644 --- a/libbe/tests.py +++ b/libbe/tests.py @@ -27,3 +27,12 @@ def arch_dir(): def bug_arch_dir(): dir = arch_dir() return bugdir.create_bug_dir(dir.name, arch) + +def simple_bug_dir(): + dir = bug_arch_dir() + bug_a = bugdir.new_bug(dir, "a") + bug_b = bugdir.new_bug(dir, "b") + bug_b.status = "closed" + bug_a.save() + bug_b.save() + return dir |