Ensure that Arch tests have a user id set
authorAaron Bentley <abentley@panoramicfeedback.com>
Mon, 16 Jul 2007 16:22:59 +0000 (12:22 -0400)
committerAaron Bentley <abentley@panoramicfeedback.com>
Mon, 16 Jul 2007 16:22:59 +0000 (12:22 -0400)
libbe/arch.py
libbe/tests.py

index b7c8a0b6559c3479a61194d4e09433c107e5d761..624aea3664e72e3ddbecafade236cf72980a8741 100644 (file)
@@ -41,6 +41,25 @@ def invoke_client(*args, **kwargs):
         raise Exception("Command failed: %s" % error)
     return output
 
+def get_user_id():
+    try:
+        return invoke_client('my-id')
+    except Exception, e:
+        if 'no arch user id set' in e.args[0]:
+            return None
+        else:
+            raise
+
+
+def set_user_id(value):
+    invoke_client('my-id', value)
+
+
+def ensure_user_id():
+    if get_user_id() is None:
+        set_user_id('nobody <nobody@example.com>')
+
 def write_tree_settings(contents, path):
     file(os.path.join(path, "{arch}", "=tagging-method"), "wb").write(contents)
 
@@ -49,6 +68,7 @@ def init_tree(path):
 
 def temp_arch_tree(type="easy"):
     import tempfile
+    ensure_user_id()
     path = tempfile.mkdtemp()
     init_tree(path)
     if type=="easy":
index 2662df19ad4f9c9f27a939e262c90b2bff607b16..a7d925dea17a66685344a32254f5c787231ab563 100644 (file)
@@ -36,6 +36,7 @@ class Dir:
         shutil.rmtree(self.name)
 
 def arch_dir():
+    arch.ensure_user_id()
     dir = Dir()
     arch.init_tree(dir.name)
     return dir