]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Add test to list remote collective dir
authorDavid Stainton <dstainton415@gmail.com>
Fri, 26 Jun 2015 19:14:14 +0000 (12:14 -0700)
committerDaira Hopwood <daira@jacaranda.org>
Wed, 30 Sep 2015 15:45:22 +0000 (16:45 +0100)
here you can see that i've avoided tampering with many of our
unit tests by making collective_dirnode conditional.
instead perhaps our unit tests should fail if collective_cap
is blank.

src/allmydata/frontends/magic_folder.py
src/allmydata/test/test_magic_folder.py

index 85cdd04f27d1b7bde5941b2b22f502b37959b4a7..4827b2457d670398bd0289832b86dcde0540531e 100644 (file)
@@ -71,6 +71,14 @@ class MagicFolder(service.MultiService):
 
         # TODO: allow a path rather than a cap URI.
         self._upload_dirnode = self._client.create_node_from_uri(upload_dircap)
+        if collective_dircap != "":
+            # XXX this condition used for some unit tests
+            self._collective_dirnode = self._client.create_node_from_uri(collective_dircap)
+            if not IDirectoryNode.providedBy(self._collective_dirnode):
+                raise AssertionError("The URI in 'private/collective_dircap' does not refer to a directory.")
+            if self._collective_dirnode.is_unknown() or not self._collective_dirnode.is_readonly():
+                raise AssertionError("The URI in 'private/collective_dircap' is not a readonly cap to a directory.")
+
         if not IDirectoryNode.providedBy(self._upload_dirnode):
             raise AssertionError("The URI in 'private/magic_folder_dircap' does not refer to a directory.")
         if self._upload_dirnode.is_unknown() or self._upload_dirnode.is_readonly():
@@ -98,6 +106,9 @@ class MagicFolder(service.MultiService):
         self._notifier.watch(self._local_path, mask=self.mask, callbacks=[self._notify],
                              recursive=True)
 
+    def _scan_remote_collective(self):
+        return self._collective_dirnode.list()
+        
     def _db_file_is_uploaded(self, childpath):
         """_db_file_is_uploaded returns true if the file was previously uploaded
         """ 
index c746b2304261edaeb7c0c74cd8202c8787cfa629..c809e8ad9365835f6915d1c9ee46da70d66ee7fc 100644 (file)
@@ -52,7 +52,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         self.failUnless(IDirectoryNode.providedBy(n))
         self.upload_dirnode = n
         self.upload_dircap = n.get_uri()
-        self.collective_dircap = "abc123"
+        self.collective_dircap = ""
 
     def _create_magicfolder(self, ign):
         dbfile = abspath_expanduser_unicode(u"magicfolderdb.sqlite", base=self.basedir)
@@ -321,6 +321,22 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_queued'), 0))
         return d
 
+    def test_remote_scan(self):
+        self.set_up_grid()
+        self.local_dir = abspath_expanduser_unicode(self.unicode_or_fallback(u"l\u00F8cal_dir", u"local_dir"),
+                                                    base=self.basedir)
+        self.mkdir_nonascii(self.local_dir)
+        self.client = self.g.clients[0]
+        self.stats_provider = self.client.stats_provider
+        d = self.create_invite_join_magic_folder(u"Alice", self.local_dir)
+        d.addCallback(self._create_magicfolder)
+        d.addCallback(lambda x: self.magicfolder._scan_remote_collective())
+        def display_list(results):
+            print "LIST ", results
+        d.addCallback(display_list)
+        d.addBoth(self._cleanup)
+        return d
+
 
 class MockTest(MagicFolderTestMixin, unittest.TestCase):
     """This can run on any platform, and even if twisted.internet.inotify can't be imported."""