def test_dst_gen_per_db(self, transfer, mysql_svc, *args, **kwargs): mysqldump = backup.Backup(type='mysqldump', cloudfs_dir='s3://scalr-1a8f341e/backups/mysql/1265/', chunk_size=512) mysqldump._databases = ['db1', 'db2'] for db in mysqldump._databases: mysqldump._current_db = db assert mysqldump._gen_dst().next() == os.path.join(mysqldump.cloudfs_dir, mysqldump._current_db)
def test_run(self, transfer, mysql_svc, *args, **kwargs): mysqldump = backup.Backup(type='mysqldump', cloudfs_dir='s3://scalr-1a8f341e/backups/mysql/1265/', chunk_size=512) mysql_svc.MySQLClient.list_databases.return_value = ['db1', 'db2'] mysqldump.run() mysql_svc.MySQLClient.assert_called_once_with(mysql2.__mysql__['root_user'], mysql2.__mysql__['root_password']) mysql_svc.MySQLClient.list_databases.assert_called_once_with() transfer.assert_called_once_with(mock.ANY, mock.ANY, 'upload', tar_it=False, chunk_size=512)
def test_src_gen_one(self, popen, transfer, mysql_svc, *args, **kwargs): mysqldump = backup.Backup(type='mysqldump', cloudfs_dir='s3://scalr-1a8f341e/backups/mysql/1265/', chunk_size=512, file_per_databse=False) mysqldump._databases = ['db1', 'db2'] backups = list(mysqldump._gen_src()) assert len(backups) == popen.stdout.call_count assert len(backups) == 1 assert mock.call(linux.build_cmd_args( executable='/usr/bin/mysqldump', params=mysql2.__mysql__['mysqldump_options'].split() + ['--all-databases'])) in popen.call_list()
def test_dst_gen_one(self, transfer, mysql_svc, *args, **kwargs): mysqldump = backup.Backup(type='mysqldump', cloudfs_dir='s3://scalr-1a8f341e/backups/mysql/1265/', chunk_size=512, file_per_databse=False) assert mysqldump._gen_dst().next() == os.path.join(self.cloudfs_dir, 'mysql')