add test for symlinks
authorKevin Dangoor <kdangoor@mozilla.com>
Sat, 19 Sep 2009 16:41:21 -0400
changeset 2697 bfe6e111286aa63a891eda2e1abe91f440cf94bd
parent 2696 81bec9c03b978fa0267d9beedf91078b004150c1
child 2698 c529a24afaf6edfbd69d179037ecb7257b8b86bc
push id1134
push userkdangoor@mozilla.com
push dateSun, 20 Sep 2009 03:05:03 +0000
add test for symlinks
backend/python/bespin/filesystem.py
backend/python/bespin/tests/test_files.py
--- a/backend/python/bespin/filesystem.py
+++ b/backend/python/bespin/filesystem.py
@@ -178,16 +178,18 @@ class File(object):
         # chop off any leading slashes
         while name and name.startswith("/"):
             name = name[1:]
 
         self.project = project
         self.name = name
         self.location = project.location / name
         self._info = None
+        if self.location.islink():
+            raise FSException("That path is a symlink, and symlinks are not supported.")
 
     @property
     def short_name(self):
         return self.location.basename()
 
     def exists(self):
         return self.location.exists()
 
--- a/backend/python/bespin/tests/test_files.py
+++ b/backend/python/bespin/tests/test_files.py
@@ -734,9 +734,22 @@ def test_install_template_files():
             simplejson.dumps(dict(stdtemplate="jetpacks/sidebar.js",
                 values=dict(templateName="mysidebar"))))
     jetpacks = get_project(macgyver, macgyver, "jetpacks")
     datafile = jetpacks.get_file_object("mysidebar.html")
     
     data = datafile.data
     # add assertions here once this is finalized.
     pass
-    
\ No newline at end of file
+    
+def test_handling_of_symlinks():
+    _init_data()
+    bigmac = get_project(macgyver, macgyver, "bigmac", create=True)
+    linksource = bigmac.location / "thefile"
+    linksource.write_bytes("Hi")
+    linkdest = bigmac.location / "thelink"
+    linksource.symlink(linkdest)
+    assert linkdest.exists()
+    assert linkdest.islink()
+    resp = app.get("/file/at/bigmac/thelink", status=400)
+    resp = app.put("/file/at/bigmac/thelink", "new data", status=400)
+    assert linksource.bytes() == "Hi"
+