Implemented tests for 'open'
authorAaron Bentley <abentley@panoramicfeedback.com>
Thu, 24 Mar 2005 15:40:30 +0000 (15:40 +0000)
committerAaron Bentley <abentley@panoramicfeedback.com>
Thu, 24 Mar 2005 15:40:30 +0000 (15:40 +0000)
becommands/close.py
libbe/bugdir.py
libbe/tests.py

index 2344a90e097195e9a5e6637aab11eb613044b46d..4f50b58efa8d2ef49b6f19e60c71c8a0b8efd08f 100644 (file)
@@ -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"
index d81c616d7fe3a62bdf136bbdabbac0114981b65c..16c1544746e2b5b71bcdc55f3dc4b1951db4e524 100644 (file)
@@ -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"
index b6d30836ea47a4dd65d2874f1b1c02e50769e8d4..c5b9f497ead45ef8dbf18e0a615813cd93654cce 100644 (file)
@@ -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