def testNewEmptyRepositoryByWalking(self):
     self._setup_test_repo()
     base_dirpath, ll_dirs, ll_files = nodup_archiving.walk_dir(self.REPO_TEST_DIR)
     self.assertEqual(base_dirpath, self.REPO_TEST_DIR, "Expected base path to be '%s' but got '%s'." % (self.REPO_TEST_DIR,base_dirpath))
     self.assertEqual(273, len(ll_dirs), 'Expected %d directories but got %d.' % (2,len(ll_dirs)))
     self.assertEqual(0, len(ll_files), 'Expected %d files but got %d.' % (6,len(ll_files)))
     self._remove_test_repo()
 def testActionArchive(self):
     self._setup_test_repo()
     self.sut.action_archive()
     base_dirpath, ll_dirs, ll_files = nodup_archiving.walk_dir(self.REPO_TEST_DIR)
     self.assertEqual(self.REPO_TEST_DIR, base_dirpath, "Expected '%s' but got '%s'" % (self.REPO_TEST_DIR, base_dirpath))
     lendirs = len(ll_dirs)
     expected_dirs = 277
     self.assertEqual(lendirs, expected_dirs, "Expected %d directories, but got %d." % (lendirs, expected_dirs))
     lenfiles = len(ll_files)
     expected_files = 11
     self.assertEqual(lenfiles, expected_files, "Expected %d files, but got %d." % (lenfiles, expected_files))
     self._remove_test_repo()
    def testActionRestore(self):
        ## setup
        self._setup_test_repo()
        self.sut.action_archive()
        save_path = self.sut.argd['toarchpath'] ## for subsequent tests
        self.sut.argd['toarchpath'] = self.RESTORED_DATA_DIR
        self.sut.action_restore()

        ## test whether restored directory is OK
        base_dirpath, ll_dirs, ll_files = nodup_archiving.walk_dir(self.RESTORED_DATA_DIR)
        actual = self.RESTORED_DATA_DIR
        self.assertEqual(base_dirpath, actual, "Expected base path to be '%s' but got '%s'." % (actual,base_dirpath))
        self.assertEqual(3, len(ll_dirs), 'Expected %d directories but got %d.' % (2,len(ll_dirs)))
        self.assertEqual(7, len(ll_files), 'Expected %d files but got %d.' % (6,len(ll_files)))

        ## cleanup
        self._remove_test_repo()
        shutil.rmtree(self.RESTORED_DATA_DIR)
        self.sut.argd['toarchpath'] = save_path ## for subsequent tests
 def testWalkDirectory(self):
     base_dirpath, ll_dirs, ll_files = nodup_archiving.walk_dir(self.TEST_DATA_DIR)
     self.assertEqual(base_dirpath, self.TEST_DATA_DIR, "Expected base path to be '%s' but got '%s'." % (self.TEST_DATA_DIR,base_dirpath))
     self.assertEqual(3, len(ll_dirs), 'Expected %d directories but got %d.' % (2,len(ll_dirs)))
     self.assertEqual(7, len(ll_files), 'Expected %d files but got %d.' % (6,len(ll_files)))