Oben Sonne avatar Oben Sonne committed 5b358c3

Include autostart setup in tests

Comments (0)

Files changed (3)

 def _autostart(enable):
     """Set up XDG autostart file."""
     
-    if TEST: # don't change this file in test mode
-        return
+    if TEST:
+        fname = os.path.join(os.path.curdir, "autostart.desktop")
+    else:
+        fname = os.path.join(xdg_ch, "autostart", "gnome-encfs.desktop")
 
-    fname = os.path.join(xdg_ch, "autostart", "gnome-encfs.desktop")
-
-    if not enable and os.path.exists(fname):
-        os.remove(fname)
+    if not enable:
+        if os.path.exists(fname):
+            os.remove(fname)
         return
     
     content = {
         
         # check item data
         for other in [i for i in items if i.item_id != item.item_id]:
-            print("cmp %s - %s" % (other.attributes["mount-point"], mpoint))
             if other.attributes["mount-point"] == mpoint:
                 _proceed("mount point already in use")
         if not _is_encfs(epath):
         info.set_secret(secret)
         gk.item_set_info_sync(KEYRING, item.item_id, info)
         
+        global _items_cached
+        _items_cached = None
+    
     return True
 
 def remove_item(mpoint):
 * encfs path     : ./tenv/e1
   mount point    : ./tenv/m1
   mount at login : yes
-cmp ./tenv/m3a
-cmp ./tenv/m3a
 # EXPECT: 3 items (1,2,3a)
 * encfs path     : ./tenv/e3
   mount point    : ./tenv/m3a
 * encfs path     : ./tenv/e1
   mount point    : ./tenv/m1
   mount at login : yes
-cmp ./tenv/m3a
-cmp ./tenv/m3a
 # EXPECT: 3 items (1,2,3a)
 * encfs path     : ./tenv/e3
   mount point    : ./tenv/m3a
 # EXPECT: 1 failing mount (3a) - wrong password
 Mounting ./tenv/m3a: Error decoding volume key, password incorrect
 # EXPECT: no mounted paths
-cmp ./tenv/m3b
-cmp ./tenv/m3b
 # EXPECT: 3 items (1,2,3b)
 * encfs path     : ./tenv/e3
   mount point    : ./tenv/m3b
 encfs on ./tenv/m3b type fuse.encfs (rw,nosuid,nodev,default_permissions,)
 # EXPECT: no mounted paths - all unmounted
 # EXPECT: failing edit (3b->2) - mount point in use
-cmp ./tenv/m2
 Warning: mount point already in use
 # EXPECT: 3 items (1,2,3b)
 * encfs path     : ./tenv/e3
 * encfs path     : ./tenv/e1
   mount point    : ./tenv/m1
   mount at login : yes
+# EXPECT: autostart on
+autostart on
+# EXPECT: 2 succeeding edits
+# EXPECT: autostart on
+autostart on
+# EXPECT: autostart content
+[Desktop Entry]
+Comment=Mount EncFS folders configured in GNOME's keyring
+Name=EncFS
+Exec=gnome-encfs autostart
+Encoding=UTF-8
+Version=1.0
+Type=Application
+X-GNOME-Autostart-enabled=true
+Icon=folder
+
+# EXPECT: 1 succeeding edits
+# EXPECT: autostart off
+autostart off
+# EXPECT: no listed items
+# EXPECT: autostart off
+autostart off
 $GENCFS -e $TENV/m3b --password p3 --epath $TENV/e3 --mpoint $TENV/m2 --proceed n --amount y
 expect "3 items (1,2,3b)"
 $GENCFS -l
+expect "autostart on"
+test -e autostart.desktop && echo "autostart on" ||  echo "autostart off"
+expect "2 succeeding edits"
+$GENCFS -e $TENV/m1 --password p1 --epath $TENV/e1 --mpoint $TENV/m1 --proceed n --amount n
+$GENCFS -e $TENV/m2 --password p2 --epath $TENV/e2 --mpoint $TENV/m2 --proceed n --amount n
+expect "autostart on"
+test -e autostart.desktop && echo "autostart on" ||  echo "autostart off"
+expect "autostart content"
+cat autostart.desktop
+expect "1 succeeding edits"
+$GENCFS -e $TENV/m3b --password p3 --epath $TENV/e3 --mpoint $TENV/m3b --proceed n --amount n
+expect "autostart off"
+test -e autostart.desktop && echo "autostart on" ||  echo "autostart off"
 
 # clean up keyring
 $GENCFS -l | grep "mount point" | grep "/tenv/m[0-9]" | awk {'print $4'} | \
     while read MP ; do $GENCFS -r $MP ; done
 
+expect "no listed items"
+$GENCFS -l
+expect "autostart off"
+test -e autostart.desktop && echo "autostart on" ||  echo "autostart off"
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.