def test_restore_database_dump_runs_mysql_with_hostname_and_port(): database_config = [{ 'name': 'foo', 'hostname': 'database.example.org', 'port': 5433 }] extract_process = flexmock(stdout=flexmock()) flexmock(module).should_receive( 'execute_command_with_processes').with_args( ( 'mysql', '--batch', '--verbose', '--host', 'database.example.org', '--port', '5433', '--protocol', 'tcp', ), processes=[extract_process], output_log_level=logging.DEBUG, input_file=extract_process.stdout, extra_environment=None, borg_local_path='borg', ).once() module.restore_database_dump(database_config, 'test.yaml', {}, dry_run=False, extract_process=extract_process)
def test_restore_database_dump_with_dry_run_skips_restore(): database_config = [{'name': 'foo'}] flexmock(module).should_receive('execute_command_with_processes').never() module.restore_database_dump(database_config, 'test.yaml', {}, dry_run=True, extract_process=flexmock())
def test_restore_database_dump_errors_on_multiple_database_config(): database_config = [{'name': 'foo'}, {'name': 'bar'}] flexmock(module).should_receive('execute_command_with_processes').never() flexmock(module).should_receive('execute_command').never() with pytest.raises(ValueError): module.restore_database_dump(database_config, 'test.yaml', {}, dry_run=False, extract_process=flexmock())
def test_restore_database_dump_runs_mysql_with_username_and_password(): database_config = [{ 'name': 'foo', 'username': '******', 'password': '******' }] extract_process = flexmock(stdout=flexmock()) flexmock(module).should_receive( 'execute_command_with_processes').with_args( ('mysql', '--batch', '--verbose', '--user', 'root'), processes=[extract_process], output_log_level=logging.DEBUG, input_file=extract_process.stdout, extra_environment={ 'MYSQL_PWD': 'trustsome1' }, borg_local_path='borg', ).once() module.restore_database_dump(database_config, 'test.yaml', {}, dry_run=False, extract_process=extract_process)