~rye/ubuntuone-client/unique-check-is-unique

« back to all changes in this revision

Viewing changes to tests/syncdaemon/test_fsm.py

  • Committer: Tarmac
  • Author(s): facundo at com
  • Date: 2010-09-13 20:36:05 UTC
  • mfrom: (687.1.1 auto-conflict)
  • Revision ID: tarmac-20100913203605-74vkvw2pnml0x8oq
Don't generate a new file if we're deleting or overwriting it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1456
1456
 
1457
1457
    def test_move_overwriting(self):
1458
1458
        """Test that move refreshes stat when overwrites other file."""
 
1459
        self.fsm.create(self.share_path, self.share.id, is_dir=True)
1459
1460
        path1 = os.path.join(self.share.path, "thisfile1")
1460
1461
        path2 = os.path.join(self.share.path, "thisfile2")
1461
1462
        open(path1, "w").close()
1682
1683
        self.fsm.remove_partial("uuid", "share")
1683
1684
 
1684
1685
    def test_ro_share(self):
1685
 
        """
1686
 
        Test that creating a partial of a ro share leave the partials dir
1687
 
        permissions intact.
 
1686
        """Test creating a partial of a RO share.
 
1687
 
 
1688
        It should leave the partials dir permissions intact.
1688
1689
        """
1689
1690
        share = self.create_share('ro_share', 'ro_share_name',
1690
1691
                                  self.fsm, self.shares_dir,
1823
1824
 
1824
1825
    def test_move_file_overwrite(self):
1825
1826
        """Test that a file is moved over other one."""
 
1827
        self.fsm.create(self.share_path, self.share.id,
 
1828
                        self.share.node_id, is_dir=True)
1826
1829
        testfile1 = os.path.join(self.share_path, "path1")
1827
1830
        mdid1 = self.fsm.create(testfile1, "share")
1828
1831
        self.fsm.set_node_id(testfile1, "uuid1")
1846
1849
        mdobj = self.fsm.get_by_path(testfile2)
1847
1850
        self.assertEqual(mdobj.mdid, mdid1)
1848
1851
 
1849
 
        # check that the info for the overwritten one is gone
 
1852
        # check that the info for the overwritten one is gone to trash
1850
1853
        self.assert_no_metadata(mdid2, testfile1, "share", "uuid2")
 
1854
        self.assertEqual(self.fsm.trash[(self.share.id, "uuid2")],
 
1855
                         (mdid2, self.share.node_id, testfile2))
1851
1856
 
1852
1857
    def test_move_file_withdir(self):
1853
1858
        """Test that a dir is moved from one point to the other."""
2156
2161
        self.assertTrue(self.fsm.has_metadata(mdid=mdid))
2157
2162
        self.assertEqual(self.fsm.trash, {})
2158
2163
        self.assertEqual(list(self.fsm.get_iter_trash()), [])
 
2164
        self.assertFalse(self.fsm.node_in_trash("share", "uuid"))
2159
2165
 
2160
2166
        # delete to trash
2161
2167
        self.fsm.delete_to_trash(mdid, "parent")
2164
2170
                         {("share", "uuid"): (mdid, "parent", testfile)})
2165
2171
        self.assertEqual(list(self.fsm.get_iter_trash()),
2166
2172
                         [("share", "uuid", "parent")])
 
2173
        self.assertTrue(self.fsm.node_in_trash("share", "uuid"))
2167
2174
 
2168
2175
        # remove from trash
2169
2176
        self.fsm.remove_from_trash("share", "uuid")
2170
2177
        self.assertFalse(self.fsm.has_metadata(mdid=mdid))
2171
2178
        self.assertEqual(self.fsm.trash, {})
2172
2179
        self.assertEqual(list(self.fsm.get_iter_trash()), [])
 
2180
        self.assertFalse(self.fsm.node_in_trash("share", "uuid"))
2173
2181
 
2174
2182
    def test_trash_old(self):
2175
2183
        """Test that get_iter_trash supports old trash."""