Esempio n. 1
0
def test_dir_copy_to_new_dir ():
  target_name = uuid.uuid1 ().hex
  source = os.path.join (TEST_ROOT, "a")
  target = os.path.join (TEST_ROOT, target_name)
  assert not os.path.isdir (target)
  fs.copy (source, target)
  assert dirs_are_equal (source, target)
Esempio n. 2
0
def test_dir_copy_to_new_dir():
    target_name = uuid.uuid1().hex
    source = os.path.join(TEST_ROOT, "a")
    target = os.path.join(TEST_ROOT, target_name)
    assert not os.path.isdir(target)
    fs.copy(source, target)
    assert dirs_are_equal(source, target)
Esempio n. 3
0
 def test_dir_copy_to_new_dir (self):
   source_name = uuid.uuid1 ().hex
   target_name = uuid.uuid1 ().hex
   source = os.path.join (utils.TEST_ROOT, source_name)
   target = os.path.join (utils.TEST_ROOT, target_name)
   os.mkdir (source)
   for i in range (10):
     open (os.path.join (source, "%d.dat" % i), "w").close ()
   self.assertTrue (os.path.isdir (source))
   self.assertFalse (os.path.isdir (target))
   fs.copy (source, target)
   self.assertTrue (*utils.dirs_are_equal (source, target))
 def test_dir_copy_to_new_dir(self):
     source_name = uuid.uuid1().hex
     target_name = uuid.uuid1().hex
     source = os.path.join(utils.TEST_ROOT, source_name)
     target = os.path.join(utils.TEST_ROOT, target_name)
     os.mkdir(source)
     for i in range(10):
         open(os.path.join(source, "%d.dat" % i), "w").close()
     self.assertTrue(os.path.isdir(source))
     self.assertFalse(os.path.isdir(target))
     fs.copy(source, target)
     self.assertTrue(*utils.dirs_are_equal(source, target))
Esempio n. 5
0
  def test_dir_copy_with_callback (self):
    callback_result = []
    def _callback (total_size, size_so_far, data):
      callback_result.append ((total_size, size_so_far, data))

    source_name = uuid.uuid1 ().hex
    target_name = uuid.uuid1 ().hex
    callback_data = uuid.uuid1 ().hex
    source = os.path.join (utils.TEST_ROOT, source_name)
    target = os.path.join (utils.TEST_ROOT, target_name)
    os.mkdir (source)
    for i in range (10):
      open (os.path.join (source, "%d.dat" % i), "w").close ()
    self.assertTrue (os.path.isdir (source))
    self.assertFalse (os.path.isdir (target))
    fs.copy (source, target, _callback, callback_data)
    self.assertTrue (*utils.dirs_are_equal (source, target))
    self.assertEquals (len (callback_result), 10)
    self.assertEquals (callback_result, [(0, 0, callback_data) for i in range (10)])
    def test_dir_copy_with_callback(self):
        callback_result = []

        def _callback(total_size, size_so_far, data):
            callback_result.append((total_size, size_so_far, data))

        source_name = uuid.uuid1().hex
        target_name = uuid.uuid1().hex
        callback_data = uuid.uuid1().hex
        source = os.path.join(utils.TEST_ROOT, source_name)
        target = os.path.join(utils.TEST_ROOT, target_name)
        os.mkdir(source)
        for i in range(10):
            open(os.path.join(source, "%d.dat" % i), "w").close()
        self.assertTrue(os.path.isdir(source))
        self.assertFalse(os.path.isdir(target))
        fs.copy(source, target, _callback, callback_data)
        self.assertTrue(*utils.dirs_are_equal(source, target))
        self.assertEquals(len(callback_result), 10)
        self.assertEquals(callback_result,
                          [(0, 0, callback_data) for i in range(10)])