PASSWORD = None
+ GIT_DIR = '.git'
+
def setUp(self):
'''
Create base test data
self.consoleLogger = logging.StreamHandler()
self.consoleLogger.setLevel(logging.DEBUG)
+ if not os.path.isdir(self.GIT_DIR):
+ # Not running inside git tree, take our
+ # own testing directory as source.
+ self.GIT_DIR = 'testing'
+
+ if not os.path.isdir(self.GIT_DIR):
+ raise Exception('No input directory found: ' + self.GIT_DIR)
+
def tearDown(self):
'''
Remove temporal files created by unit tests
deltatar = DeltaTar(mode=self.MODE, password=self.PASSWORD,
logger=self.consoleLogger)
- shutil.copytree(".git", "source_dir2")
+ shutil.copytree(self.GIT_DIR, "source_dir2")
# create first backup
deltatar.create_full_backup(
deltatar.restore_backup(target_path="source_dir2",
backup_tar_path=tar_path)
- self.check_equal_dirs('.git', 'source_dir2', deltatar)
+ self.check_equal_dirs(self.GIT_DIR, 'source_dir2', deltatar)
def test_restore_multivol_manual_from_index(self):
'''
def test_restore_from_index_diff_backup3(self):
'''
- Creates a full backup of .git, modifies some random files, creates a
+ Creates a full backup of self.GIT_DIR, modifies some random files, creates a
diff backup, then restores the diff backup with the full backup as a
starting point.
'''
logger=self.consoleLogger)
shutil.rmtree("source_dir")
- shutil.copytree(".git", "source_dir")
- shutil.copytree(".git", "source_dir_diff")
+ shutil.copytree(self.GIT_DIR, "source_dir")
+ shutil.copytree(self.GIT_DIR, "source_dir_diff")
# create first backup
deltatar.create_full_backup(
deltatar.restore_backup("target_dir", backup_tar_path=tar_path)
# and check that target_dir equals to source_dir (which is the same as
- # ".git" initially)
+ # self.GIT_DIR initially)
self.check_equal_dirs('source_dir', 'target_dir', deltatar)
# then apply diff backup in target_dir
backup_indexes_paths=[index_path, prev_index_path])
# and check that target_dir equals to source_dir_diff (the randomly
- # altered ".git" directory)
+ # altered self.GIT_DIR directory)
self.check_equal_dirs('source_dir_diff', 'target_dir', deltatar)
# then delete target_dir and apply diff backup from zero and check again
backup_indexes_paths=[index_path, prev_index_path])
# and check that target_dir equals to source_dir_diff (the randomly
- # altered ".git" directory)
+ # altered self.GIT_DIR directory)
self.check_equal_dirs('source_dir_diff', 'target_dir', deltatar)
def test_restore_from_index_diff_backup3_multivol(self):
'''
- Creates a full backup of .git, modifies some random files, creates a
+ Creates a full backup of self.GIT_DIR, modifies some random files, creates a
diff backup, then restores the diff backup with the full backup as a
starting point.
'''
logger=self.consoleLogger)
shutil.rmtree("source_dir")
- shutil.copytree(".git", "source_dir")
- shutil.copytree(".git", "source_dir_diff")
+ shutil.copytree(self.GIT_DIR, "source_dir")
+ shutil.copytree(self.GIT_DIR, "source_dir_diff")
# create first backup
deltatar.create_full_backup(
deltatar.restore_backup("target_dir", backup_tar_path=tar_path)
# and check that target_dir equals to source_dir (which is the same as
- # ".git" initially)
+ # self.GIT_DIR initially)
self.check_equal_dirs('source_dir', 'target_dir', deltatar)
# then apply diff backup in target_dir
backup_indexes_paths=[index_path, prev_index_path])
# and check that target_dir equals to source_dir_diff (the randomly
- # altered ".git" directory)
+ # altered self.GIT_DIR directory)
self.check_equal_dirs('source_dir_diff', 'target_dir', deltatar)
# then delete target_dir and apply diff backup from zero and check again
backup_indexes_paths=[index_path, prev_index_path])
# and check that target_dir equals to source_dir_diff (the randomly
- # altered ".git" directory)
+ # altered self.GIT_DIR directory)
self.check_equal_dirs('source_dir_diff', 'target_dir', deltatar)
def check_equal_dirs(self, path1, path2, deltatar):