]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Move the test for _write_download_file() to test_magic_folder module
authorRamakrishnan Muthukrishnan <ram@leastauthority.com>
Mon, 31 Aug 2015 08:24:05 +0000 (13:54 +0530)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 1 Oct 2015 00:19:47 +0000 (01:19 +0100)
src/allmydata/test/test_cli_magic_folder.py
src/allmydata/test/test_magic_folder.py

index abb2344d7ea0c6252297b5979363a772bdf07a4d..82960781bb7ee72a55a8188600f47aec3c90d69f 100644 (file)
@@ -11,7 +11,6 @@ from .test_cli import CLITestMixin
 from allmydata.scripts import magic_folder_cli
 from allmydata.util.fileutil import abspath_expanduser_unicode
 from allmydata.frontends.magic_folder import MagicFolder
-from allmydata.frontends.magic_folder import Downloader
 from allmydata import uri
 
 
@@ -202,35 +201,3 @@ class CreateMagicFolder(MagicFolderTestMixin, unittest.TestCase):
         d.addCallback(lambda x: self.check_joined_config(0, self.upload_dircap))
         d.addCallback(lambda x: self.check_config(0, self.local_dir))
         return d
-
-    def test_write_downloaded_file(self):
-        workdir = u"cli/MagicFolder/write-downloaded-file"
-        local_file = fileutil.abspath_expanduser_unicode(os.path.join(workdir, "foobar"))
-
-        # create a file with name "foobar" with content "foo"
-        # write downloaded file content "bar" into "foobar" with is_conflict = False
-        fileutil.make_dirs(workdir)
-        fileutil.write(local_file, "foo")
-
-        # if is_conflict is False, then the .conflict file shouldn't exist.
-        Downloader._write_downloaded_file(local_file, "bar", False, None)
-        conflicted_path = local_file + u".conflict"
-        self.failIf(os.path.exists(conflicted_path))
-
-        # At this point, the backup file should exist with content "foo"
-        backup_path = local_file + u".backup"
-        self.failUnless(os.path.exists(backup_path))
-        self.failUnlessEqual(fileutil.read(backup_path), "foo")
-
-        # .tmp file shouldn't exist
-        self.failIf(os.path.exists(local_file + u".tmp"))
-
-        # .. and the original file should have the new content
-        self.failUnlessEqual(fileutil.read(local_file), "bar")
-
-        # now a test for conflicted case
-        Downloader._write_downloaded_file(local_file, "bar", True, None)
-        self.failUnless(os.path.exists(conflicted_path))
-
-        # .tmp file shouldn't exist
-        self.failIf(os.path.exists(local_file + u".tmp"))
index 0a6fddf291be35b6712413155fd8bbc3228f5b48..39ecb8a39e36950c4f33097d56c9ce57fcb6d2d5 100644 (file)
@@ -16,6 +16,7 @@ from allmydata.test.test_cli_magic_folder import MagicFolderTestMixin
 
 from allmydata.frontends import magic_folder
 from allmydata.frontends.magic_folder import MagicFolder
+from allmydata.frontends.magic_folder import Downloader
 from allmydata import backupdb, magicpath
 from allmydata.util.fileutil import abspath_expanduser_unicode
 
@@ -454,6 +455,38 @@ class MockTest(MagicFolderTestMixin, unittest.TestCase):
         d.addCallback(_check_errors)
         return d
 
+    def test_write_downloaded_file(self):
+        workdir = u"cli/MagicFolder/write-downloaded-file"
+        local_file = fileutil.abspath_expanduser_unicode(os.path.join(workdir, "foobar"))
+
+        # create a file with name "foobar" with content "foo"
+        # write downloaded file content "bar" into "foobar" with is_conflict = False
+        fileutil.make_dirs(workdir)
+        fileutil.write(local_file, "foo")
+
+        # if is_conflict is False, then the .conflict file shouldn't exist.
+        Downloader._write_downloaded_file(local_file, "bar", False, None)
+        conflicted_path = local_file + u".conflict"
+        self.failIf(os.path.exists(conflicted_path))
+
+        # At this point, the backup file should exist with content "foo"
+        backup_path = local_file + u".backup"
+        self.failUnless(os.path.exists(backup_path))
+        self.failUnlessEqual(fileutil.read(backup_path), "foo")
+
+        # .tmp file shouldn't exist
+        self.failIf(os.path.exists(local_file + u".tmp"))
+
+        # .. and the original file should have the new content
+        self.failUnlessEqual(fileutil.read(local_file), "bar")
+
+        # now a test for conflicted case
+        Downloader._write_downloaded_file(local_file, "bar", True, None)
+        self.failUnless(os.path.exists(conflicted_path))
+
+        # .tmp file shouldn't exist
+        self.failIf(os.path.exists(local_file + u".tmp"))
+
 
 class RealTest(MagicFolderTestMixin, unittest.TestCase):
     """This is skipped unless both Twisted and the platform support inotify."""