From c9d73a936aac2ab6eb97f49e06e68774e5300ddc Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Tue, 27 Sep 2016 16:08:02 +0100 Subject: [PATCH 1/2] Fix Unicode-related Magic Folder test failures. fixes #2807 Signed-off-by: Daira Hopwood --- src/allmydata/test/cli/test_magic_folder.py | 23 +++++++++++++-------- src/allmydata/test/test_magic_folder.py | 16 +++++++------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/allmydata/test/cli/test_magic_folder.py b/src/allmydata/test/cli/test_magic_folder.py index 0c9009769..b1d422a28 100644 --- a/src/allmydata/test/cli/test_magic_folder.py +++ b/src/allmydata/test/cli/test_magic_folder.py @@ -11,6 +11,7 @@ from allmydata.util import fileutil from allmydata.scripts.common import get_aliases from ..no_network import GridTestMixin from .common import CLITestMixin +from allmydata.test.common_util import NonASCIIPathMixin from allmydata.scripts import magic_folder_cli from allmydata.util.fileutil import abspath_expanduser_unicode from allmydata.util.encodingutil import unicode_to_argv @@ -18,7 +19,12 @@ from allmydata.frontends.magic_folder import MagicFolder from allmydata import uri -class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin): +class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin, NonASCIIPathMixin): + def setUp(self): + GridTestMixin.setUp(self) + self.alice_nickname = self.unicode_or_fallback(u"Alice\u00F8", u"Alice") + self.bob_nickname = self.unicode_or_fallback(u"Bob\u00F8", u"Bob") + def do_create_magic_folder(self, client_num): d = self.do_cli("magic-folder", "create", "magic:", client_num=client_num) def _done((rc,stdout,stderr)): @@ -153,10 +159,9 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin): bob_magic_dir = abspath_expanduser_unicode(u"Bob-magic", base=self.basedir) self.mkdir_nonascii(bob_magic_dir) - # Alice creates a Magic Folder, - # invites herself then and joins. + # Alice creates a Magic Folder, invites herself and joins. d = self.do_create_magic_folder(0) - d.addCallback(lambda ign: self.do_invite(0, u"Alice\u00F8")) + d.addCallback(lambda ign: self.do_invite(0, self.alice_nickname)) def get_invite_code(result): self.invite_code = result[1].strip() d.addCallback(get_invite_code) @@ -174,7 +179,7 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin): d.addCallback(get_Alice_magicfolder) # Alice invites Bob. Bob joins. - d.addCallback(lambda ign: self.do_invite(0, u"Bob\u00F8")) + d.addCallback(lambda ign: self.do_invite(0, self.bob_nickname)) def get_invite_code(result): self.invite_code = result[1].strip() d.addCallback(get_invite_code) @@ -201,7 +206,7 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase): abs_local_dir_u = abspath_expanduser_unicode(unicode(local_dir), long_path=False) d = self.do_create_magic_folder(0) - d.addCallback(lambda ign: self.do_invite(0, u"Alice")) + d.addCallback(lambda ign: self.do_invite(0, self.alice_nickname)) def get_invite_code_and_join((rc, stdout, stderr)): invite_code = stdout.strip() return self.do_join(0, unicode(local_dir), invite_code) @@ -275,7 +280,7 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase): abs_local_dir_u = abspath_expanduser_unicode(unicode(local_dir), long_path=False) d = self.do_create_magic_folder(0) - d.addCallback(lambda ign: self.do_invite(0, u"Alice")) + d.addCallback(lambda ign: self.do_invite(0, self.alice_nickname)) def get_invite_code_and_join((rc, stdout, stderr)): self.invite_code = stdout.strip() return self.do_join(0, unicode(local_dir), self.invite_code) @@ -306,7 +311,7 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase): self.invite_code = None d = self.do_create_magic_folder(0) - d.addCallback(lambda ign: self.do_invite(0, u"Alice")) + d.addCallback(lambda ign: self.do_invite(0, self.alice_nickname)) def get_invite_code_and_join((rc, stdout, stderr)): self.failUnlessEqual(rc, 0) self.invite_code = stdout.strip() @@ -337,7 +342,7 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase): self.invite_code = None d = self.do_create_magic_folder(0) - d.addCallback(lambda ign: self.do_invite(0, u"Alice")) + d.addCallback(lambda ign: self.do_invite(0, self.alice_nickname)) def get_invite_code_and_join((rc, stdout, stderr)): self.failUnlessEqual(rc, 0) self.invite_code = stdout.strip() diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py index 2f650fd25..e0ed3b5c9 100644 --- a/src/allmydata/test/test_magic_folder.py +++ b/src/allmydata/test/test_magic_folder.py @@ -271,12 +271,11 @@ class CheckerMixin(object): -class MagicFolderAliceBobTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqualMixin, NonASCIIPathMixin, CheckerMixin): +class MagicFolderAliceBobTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqualMixin, CheckerMixin): inject_inotify = False def setUp(self): - # super(MagicFolderAliceBobTestMixin, self).setUp() # XXX huh, why isn't this working? - GridTestMixin.setUp(self) # XXX totally wrong + MagicFolderCLITestMixin.setUp(self) temp = self.mktemp() self.basedir = abspath_expanduser_unicode(temp.decode(get_filesystem_encoding())) # set_up_grid depends on self.basedir existing @@ -294,10 +293,9 @@ class MagicFolderAliceBobTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, Rea self.bob_magic_dir = abspath_expanduser_unicode(u"Bob-magic", base=self.basedir) self.mkdir_nonascii(self.bob_magic_dir) - # Alice creates a Magic Folder, - # invites herself then and joins. + # Alice creates a Magic Folder, invites herself and joins. d = self.do_create_magic_folder(0) - d.addCallback(lambda ign: self.do_invite(0, u"Alice\u00F8")) + d.addCallback(lambda ign: self.do_invite(0, self.alice_nickname)) def get_invite_code(result): self.invite_code = result[1].strip() d.addCallback(get_invite_code) @@ -321,7 +319,7 @@ class MagicFolderAliceBobTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, Rea d.addCallback(get_Alice_magicfolder) # Alice invites Bob. Bob joins. - d.addCallback(lambda ign: self.do_invite(0, u"Bob\u00F8")) + d.addCallback(lambda ign: self.do_invite(0, self.bob_nickname)) def get_invite_code(result): self.invite_code = result[1].strip() d.addCallback(get_invite_code) @@ -1027,7 +1025,7 @@ class SingleMagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, Reall self.local_dir = os.path.join(self.basedir, u"local_dir") self.mkdir_nonascii(self.local_dir) - d = self.create_invite_join_magic_folder(u"Alice\u0101", self.local_dir) + d = self.create_invite_join_magic_folder(self.alice_nickname, self.local_dir) d.addCallback(self._restart_client) # note: _restart_client ultimately sets self.magicfolder to not-None return d @@ -1122,7 +1120,7 @@ class SingleMagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, Reall d = defer.succeed(None) d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.dirs_monitored'), 0)) - d.addCallback(lambda ign: self.create_invite_join_magic_folder(u"Alice", self.local_dir)) + d.addCallback(lambda ign: self.create_invite_join_magic_folder(self.alice_nickname, self.local_dir)) d.addCallback(self._restart_client) d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.dirs_monitored'), 1)) From 64841e339da700e02b843efc7da78e6c894ba7cc Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Tue, 27 Sep 2016 16:16:19 +0100 Subject: [PATCH 2/2] Remove redundant use of NonASCIIPathMixin. Signed-off-by: Daira Hopwood --- src/allmydata/test/test_magic_folder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py index e0ed3b5c9..b6e150ce0 100644 --- a/src/allmydata/test/test_magic_folder.py +++ b/src/allmydata/test/test_magic_folder.py @@ -16,7 +16,7 @@ from allmydata.util import fake_inotify, fileutil from allmydata.util.encodingutil import get_filesystem_encoding, to_filepath from allmydata.util.consumer import download_to_data from allmydata.test.no_network import GridTestMixin -from allmydata.test.common_util import ReallyEqualMixin, NonASCIIPathMixin +from allmydata.test.common_util import ReallyEqualMixin from allmydata.test.common import ShouldFailMixin from .cli.test_magic_folder import MagicFolderCLITestMixin @@ -1010,7 +1010,7 @@ class MagicFolderAliceBobTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, Rea test_alice_bob.timeout = 300 -class SingleMagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqualMixin, NonASCIIPathMixin, CheckerMixin): +class SingleMagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqualMixin, CheckerMixin): """ These tests will be run both with a mock notifier, and (on platforms that support it) with the real INotify.