def test_backup_script_do_backup(self): with ludibrio.Mock() as mock_backupper: mock_backupper.iterate_queries() >> ["query1", "query2", "query3"] mock_backupper.iterate_months() >> [(2012, 1), (2012, 2), (2012, 3)] mock_backupper.tar_dump_directory( '/home/rafael/Dropbox/Programs/Apontador/Mongobackuping/PyMongodump/backup/tmp/tmp/', 'tmptmp201201') mock_backupper.tar_dump_directory( '/home/rafael/Dropbox/Programs/Apontador/Mongobackuping/PyMongodump/backup/tmp/tmp/', 'tmptmp201202') mock_backupper.tar_dump_directory( '/home/rafael/Dropbox/Programs/Apontador/Mongobackuping/PyMongodump/backup/tmp/tmp/', 'tmptmp201203') with ludibrio.Stub() as mock_dumper: mock_dumper.set_query('query1') >> None mock_dumper.set_query('query2') >> None mock_dumper.set_query('query3') >> None mock_dumper.run() >> None script = Backup.BackupScript(host="localhost", db="tmp", col="tmp", logpath="backup.log", backupper=mock_backupper, dumper=mock_dumper) script.do_backup() mock_backupper.validate()
def test_commandline_args(self): script = Backup.BackupScript(host="localhost", db="tmp", col="tmp", logpath="backup.log", startMonth='012012') timeobj = script.get_startTimeObject() self.assertEqual(timeobj.get_mongotimestamp(), 1325376000000) self.assertEqual([script.host, script.db, script.col, script.logpath], ["localhost", "tmp", "tmp", "backup.log"])
def test_create_backup_dir(self): script = Backup.BackupScript() script.create_backup_dir() self.assertTrue('backup' in get_directories())