Esempio n. 1
0
	def test_BareGitRepo_GotTempDir_TempDirIsCleaned(self, processRunnerMock):
		repoPath = super(self.__class__, self)._getBareRepoPath()
		tempDir = mkdtemp()
		try:
			backuper = Backuper(repoPath, tempDir)
			backuper.run()

			tempDirContents = listdir(tempDir)
			self.assertEqual(len(tempDirContents), 0)
		finally:
			rmtree(tempDir)
Esempio n. 2
0
	def test_BareGitRepo_GotTempDir_NoTempDirCreated(self, processRunnerMock):
		repoPath = super(self.__class__, self)._getBareRepoPath()
		tempDir = mkdtemp()
		try:
			with patch('tempfile.mkdtemp') as mkdtemp_mock:
				backuper = Backuper(repoPath, tempDir)
				backuper.run()

			self.assertFalse(mkdtemp_mock.called)
		finally:
			rmtree(tempDir)
Esempio n. 3
0
	def test_BareGitRepo_NoTempDir_TempDirIsCleaned(self, processRunnerMock):
		tempDir = mkdtemp()
		self.assertTrue(path.exists(tempDir))

		repoPath = super(self.__class__, self)._getBareRepoPath()
		with patch('tempfile.mkdtemp') as mkdtemp_mock:
			mkdtemp_mock.return_value = tempDir
			backuper = Backuper(repoPath)
			backuper.run()

		mkdtemp_mock.assert_called_once_with()
		self.assertFalse(path.exists(tempDir))
Esempio n. 4
0
def main():
	fileConfig("logging.conf")
	log = getLogger(__name__)
	log.info("PyBackup %s by %s" % (__version__, __author__))

	try:
		parser = OptionParser()
		parser.add_option("-r", "--repo", dest="repoPath", help="path to repository")
		parser.add_option("-t", "--temp", dest="tempDir", help="path to temp directory")
		(options, args) = parser.parse_args()

		backuper = Backuper(options.repoPath, options.tempDir)
		backuper.run()
	except Exception as exception:
		log.exception(exception)

	log.info("Execution finished")
Esempio n. 5
0
	def test_CommonGitRepo_Success(self, processRunnerMock):
		repoPath = super(self.__class__, self)._getCommonRepoPath()
		backuper = Backuper(repoPath)
		backuper.run()