]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/tests/util_test.py
More bugfixes from running live.
[wizard.git] / wizard / tests / util_test.py
index ad77c8838bc8671daf3120c702087d0acb1a2b3b..e4ebe91977d846ec31e0f5599bcc1fa47aaafca9 100644 (file)
@@ -9,14 +9,27 @@ class MyError(Exception):
 ERROR: Foo
 """
 
-def test_get_dir_user():
-    assert get_dir_user("/mit/ezyang/web_scripts/test-wiki") == "ezyang"
+class MyErrorWithHTML(Exception):
+    def __str__(self):
+        return """
+
+ERROR: Bar
+
+<html>
+    <title>No good!</title>
+</html>
+"""
+
+def test_dictmap():
+    assert dictmap(lambda x: x + 1, {'a': 0, 'b': 1}) == {'a': 1, 'b': 2}
 
-def test_get_dir_user_locker():
-    assert get_dir_user("/mit/apo/web_scripts/") == "apo"
+def test_get_dir_uid():
+    if os.getuid(): return # only run if on a scripts server. This is crude
+    assert get_dir_uid("/mit/ezyang/web_scripts/test-wiki") == 537864399
 
-def test_get_dir_url():
-    assert get_dir_url("/mit/ezyang/web_scripts/foo") == "http://ezyang.scripts.mit.edu/foo"
+def test_get_dir_uid_locker():
+    if os.getuid(): return
+    assert get_dir_uid("/mit/apo/web_scripts/") == 536956980
 
 def test_get_exception_name():
     try:
@@ -30,3 +43,9 @@ def test_get_exception_name_withstr():
     except MyError:
         assert get_exception_name(traceback.format_exc()) == "MyError"
 
+def test_get_exception_name_withhtml():
+    try:
+        raise MyErrorWithHTML
+    except MyErrorWithHTML:
+        assert get_exception_name(traceback.format_exc()) == "MyErrorWithHTML"
+