8285: Test that arvados.events.subscribe() is called only when needed.
authorTom Clegg <tom@curoverse.com>
Sat, 6 Feb 2016 00:39:42 +0000 (19:39 -0500)
committerTom Clegg <tom@curoverse.com>
Sat, 6 Feb 2016 00:39:42 +0000 (19:39 -0500)
Add missing TagsDirectory.want_event_subscribe().

services/fuse/arvados_fuse/fusedir.py
services/fuse/tests/test_command_args.py

index f3f3c9668576dc296eceb7bb125a8b8560d49ad9..196bb221e901e132d10db4f2bdbd7ed060f794e3 100644 (file)
@@ -641,6 +641,7 @@ will appear if it exists.
     def want_event_subscribe(self):
         return not self.pdh_only
 
+
 class RecursiveInvalidateDirectory(Directory):
     def invalidate(self):
         try:
@@ -661,6 +662,9 @@ class TagsDirectory(RecursiveInvalidateDirectory):
         self._poll = True
         self._poll_time = poll_time
 
+    def want_event_subscribe(self):
+        return True
+
     @use_counter
     def update(self):
         with llfuse.lock_released:
index 70a1e59f97cedb2918ce9e39cdbba13351707700..bb80d0a2fc94dc4c77c0f46f59414a8d00627235 100644 (file)
@@ -6,6 +6,7 @@ import functools
 import json
 import llfuse
 import logging
+import mock
 import os
 import run_test_server
 import sys
@@ -170,7 +171,8 @@ class MountArgsTest(unittest.TestCase):
         self.assertEqual(True, self.mnt.listen_for_events)
 
     @noexit
-    def test_custom(self):
+    @mock.patch('arvados.events.subscribe')
+    def test_custom(self, mock_subscribe):
         args = arvados_fuse.command.ArgumentParser().parse_args([
             '--mount-tmp', 'foo',
             '--mount-tmp', 'bar',
@@ -185,15 +187,23 @@ class MountArgsTest(unittest.TestCase):
         self.assertEqual(e.project_object['uuid'],
                          run_test_server.fixture('users')['active']['uuid'])
         self.assertEqual(True, self.mnt.listen_for_events)
+        with self.mnt:
+            pass
+        self.assertEqual(1, mock_subscribe.call_count)
 
     @noexit
-    def test_custom_no_listen(self):
+    @mock.patch('arvados.events.subscribe')
+    def test_custom_no_listen(self, mock_subscribe):
         args = arvados_fuse.command.ArgumentParser().parse_args([
+            '--mount-by-pdh', 'pdh',
             '--mount-tmp', 'foo',
             '--mount-tmp', 'bar',
             '--foreground', self.mntdir])
         self.mnt = arvados_fuse.command.Mount(args)
         self.assertEqual(False, self.mnt.listen_for_events)
+        with self.mnt:
+            pass
+        self.assertEqual(0, mock_subscribe.call_count)
 
     def test_custom_unsupported_layouts(self):
         for name in ['.', '..', '', 'foo/bar', '/foo']: