test_mysql.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. import logging
  2. import pytest
  3. from flexmock import flexmock
  4. from borgmatic.hooks.data_source import mysql as module
  5. def test_database_names_to_dump_passes_through_name():
  6. extra_environment = flexmock()
  7. names = module.database_names_to_dump({'name': 'foo'}, extra_environment, dry_run=False)
  8. assert names == ('foo',)
  9. def test_database_names_to_dump_bails_for_dry_run():
  10. extra_environment = flexmock()
  11. flexmock(module).should_receive('execute_command_and_capture_output').never()
  12. names = module.database_names_to_dump({'name': 'all'}, extra_environment, dry_run=True)
  13. assert names == ()
  14. def test_database_names_to_dump_queries_mysql_for_database_names():
  15. extra_environment = flexmock()
  16. flexmock(module).should_receive('execute_command_and_capture_output').with_args(
  17. ('mysql', '--skip-column-names', '--batch', '--execute', 'show schemas'),
  18. extra_environment=extra_environment,
  19. ).and_return('foo\nbar\nmysql\n').once()
  20. names = module.database_names_to_dump({'name': 'all'}, extra_environment, dry_run=False)
  21. assert names == ('foo', 'bar')
  22. def test_use_streaming_true_for_any_databases():
  23. assert module.use_streaming(
  24. databases=[flexmock(), flexmock()],
  25. config=flexmock(),
  26. )
  27. def test_use_streaming_false_for_no_databases():
  28. assert not module.use_streaming(databases=[], config=flexmock())
  29. def test_dump_data_sources_dumps_each_database():
  30. databases = [{'name': 'foo'}, {'name': 'bar'}]
  31. processes = [flexmock(), flexmock()]
  32. flexmock(module).should_receive('make_dump_path').and_return('')
  33. flexmock(module).should_receive('database_names_to_dump').and_return(('foo',)).and_return(
  34. ('bar',)
  35. )
  36. for name, process in zip(('foo', 'bar'), processes):
  37. flexmock(module).should_receive('execute_dump_command').with_args(
  38. database={'name': name},
  39. dump_path=object,
  40. database_names=(name,),
  41. extra_environment=object,
  42. dry_run=object,
  43. dry_run_label=object,
  44. ).and_return(process).once()
  45. assert (
  46. module.dump_data_sources(
  47. databases,
  48. {},
  49. config_paths=('test.yaml',),
  50. borgmatic_runtime_directory='/run/borgmatic',
  51. patterns=[],
  52. dry_run=False,
  53. )
  54. == processes
  55. )
  56. def test_dump_data_sources_dumps_with_password():
  57. database = {'name': 'foo', 'username': 'root', 'password': 'trustsome1'}
  58. process = flexmock()
  59. flexmock(module).should_receive('make_dump_path').and_return('')
  60. flexmock(module).should_receive('database_names_to_dump').and_return(('foo',)).and_return(
  61. ('bar',)
  62. )
  63. flexmock(module).should_receive('execute_dump_command').with_args(
  64. database=database,
  65. dump_path=object,
  66. database_names=('foo',),
  67. extra_environment={'MYSQL_PWD': 'trustsome1'},
  68. dry_run=object,
  69. dry_run_label=object,
  70. ).and_return(process).once()
  71. assert module.dump_data_sources(
  72. [database],
  73. {},
  74. config_paths=('test.yaml',),
  75. borgmatic_runtime_directory='/run/borgmatic',
  76. patterns=[],
  77. dry_run=False,
  78. ) == [process]
  79. def test_dump_data_sources_dumps_all_databases_at_once():
  80. databases = [{'name': 'all'}]
  81. process = flexmock()
  82. flexmock(module).should_receive('make_dump_path').and_return('')
  83. flexmock(module).should_receive('database_names_to_dump').and_return(('foo', 'bar'))
  84. flexmock(module).should_receive('execute_dump_command').with_args(
  85. database={'name': 'all'},
  86. dump_path=object,
  87. database_names=('foo', 'bar'),
  88. extra_environment=object,
  89. dry_run=object,
  90. dry_run_label=object,
  91. ).and_return(process).once()
  92. assert module.dump_data_sources(
  93. databases,
  94. {},
  95. config_paths=('test.yaml',),
  96. borgmatic_runtime_directory='/run/borgmatic',
  97. patterns=[],
  98. dry_run=False,
  99. ) == [process]
  100. def test_dump_data_sources_dumps_all_databases_separately_when_format_configured():
  101. databases = [{'name': 'all', 'format': 'sql'}]
  102. processes = [flexmock(), flexmock()]
  103. flexmock(module).should_receive('make_dump_path').and_return('')
  104. flexmock(module).should_receive('database_names_to_dump').and_return(('foo', 'bar'))
  105. for name, process in zip(('foo', 'bar'), processes):
  106. flexmock(module).should_receive('execute_dump_command').with_args(
  107. database={'name': name, 'format': 'sql'},
  108. dump_path=object,
  109. database_names=(name,),
  110. extra_environment=object,
  111. dry_run=object,
  112. dry_run_label=object,
  113. ).and_return(process).once()
  114. assert (
  115. module.dump_data_sources(
  116. databases,
  117. {},
  118. config_paths=('test.yaml',),
  119. borgmatic_runtime_directory='/run/borgmatic',
  120. patterns=[],
  121. dry_run=False,
  122. )
  123. == processes
  124. )
  125. def test_database_names_to_dump_runs_mysql_with_list_options():
  126. database = {'name': 'all', 'list_options': '--defaults-extra-file=my.cnf'}
  127. flexmock(module).should_receive('execute_command_and_capture_output').with_args(
  128. (
  129. 'mysql',
  130. '--defaults-extra-file=my.cnf',
  131. '--skip-column-names',
  132. '--batch',
  133. '--execute',
  134. 'show schemas',
  135. ),
  136. extra_environment=None,
  137. ).and_return(('foo\nbar')).once()
  138. assert module.database_names_to_dump(database, None, '') == ('foo', 'bar')
  139. def test_database_names_to_dump_runs_non_default_mysql_with_list_options():
  140. database = {
  141. 'name': 'all',
  142. 'list_options': '--defaults-extra-file=my.cnf',
  143. 'mysql_command': 'custom_mysql',
  144. }
  145. flexmock(module).should_receive('execute_command_and_capture_output').with_args(
  146. extra_environment=None,
  147. full_command=(
  148. 'custom_mysql', # Custom MySQL command
  149. '--defaults-extra-file=my.cnf',
  150. '--skip-column-names',
  151. '--batch',
  152. '--execute',
  153. 'show schemas',
  154. ),
  155. ).and_return(('foo\nbar')).once()
  156. assert module.database_names_to_dump(database, None, '') == ('foo', 'bar')
  157. def test_execute_dump_command_runs_mysqldump():
  158. process = flexmock()
  159. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  160. flexmock(module.os.path).should_receive('exists').and_return(False)
  161. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  162. flexmock(module).should_receive('execute_command').with_args(
  163. (
  164. 'mysqldump',
  165. '--add-drop-database',
  166. '--databases',
  167. 'foo',
  168. '--result-file',
  169. 'dump',
  170. ),
  171. extra_environment=None,
  172. run_to_completion=False,
  173. ).and_return(process).once()
  174. assert (
  175. module.execute_dump_command(
  176. database={'name': 'foo'},
  177. dump_path=flexmock(),
  178. database_names=('foo',),
  179. extra_environment=None,
  180. dry_run=False,
  181. dry_run_label='',
  182. )
  183. == process
  184. )
  185. def test_execute_dump_command_runs_mysqldump_without_add_drop_database():
  186. process = flexmock()
  187. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  188. flexmock(module.os.path).should_receive('exists').and_return(False)
  189. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  190. flexmock(module).should_receive('execute_command').with_args(
  191. (
  192. 'mysqldump',
  193. '--databases',
  194. 'foo',
  195. '--result-file',
  196. 'dump',
  197. ),
  198. extra_environment=None,
  199. run_to_completion=False,
  200. ).and_return(process).once()
  201. assert (
  202. module.execute_dump_command(
  203. database={'name': 'foo', 'add_drop_database': False},
  204. dump_path=flexmock(),
  205. database_names=('foo',),
  206. extra_environment=None,
  207. dry_run=False,
  208. dry_run_label='',
  209. )
  210. == process
  211. )
  212. def test_execute_dump_command_runs_mysqldump_with_hostname_and_port():
  213. process = flexmock()
  214. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  215. flexmock(module.os.path).should_receive('exists').and_return(False)
  216. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  217. flexmock(module).should_receive('execute_command').with_args(
  218. (
  219. 'mysqldump',
  220. '--add-drop-database',
  221. '--host',
  222. 'database.example.org',
  223. '--port',
  224. '5433',
  225. '--protocol',
  226. 'tcp',
  227. '--databases',
  228. 'foo',
  229. '--result-file',
  230. 'dump',
  231. ),
  232. extra_environment=None,
  233. run_to_completion=False,
  234. ).and_return(process).once()
  235. assert (
  236. module.execute_dump_command(
  237. database={'name': 'foo', 'hostname': 'database.example.org', 'port': 5433},
  238. dump_path=flexmock(),
  239. database_names=('foo',),
  240. extra_environment=None,
  241. dry_run=False,
  242. dry_run_label='',
  243. )
  244. == process
  245. )
  246. def test_execute_dump_command_runs_mysqldump_with_username_and_password():
  247. process = flexmock()
  248. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  249. flexmock(module.os.path).should_receive('exists').and_return(False)
  250. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  251. flexmock(module).should_receive('execute_command').with_args(
  252. (
  253. 'mysqldump',
  254. '--add-drop-database',
  255. '--user',
  256. 'root',
  257. '--databases',
  258. 'foo',
  259. '--result-file',
  260. 'dump',
  261. ),
  262. extra_environment={'MYSQL_PWD': 'trustsome1'},
  263. run_to_completion=False,
  264. ).and_return(process).once()
  265. assert (
  266. module.execute_dump_command(
  267. database={'name': 'foo', 'username': 'root', 'password': 'trustsome1'},
  268. dump_path=flexmock(),
  269. database_names=('foo',),
  270. extra_environment={'MYSQL_PWD': 'trustsome1'},
  271. dry_run=False,
  272. dry_run_label='',
  273. )
  274. == process
  275. )
  276. def test_execute_dump_command_runs_mysqldump_with_options():
  277. process = flexmock()
  278. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  279. flexmock(module.os.path).should_receive('exists').and_return(False)
  280. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  281. flexmock(module).should_receive('execute_command').with_args(
  282. (
  283. 'mysqldump',
  284. '--stuff=such',
  285. '--add-drop-database',
  286. '--databases',
  287. 'foo',
  288. '--result-file',
  289. 'dump',
  290. ),
  291. extra_environment=None,
  292. run_to_completion=False,
  293. ).and_return(process).once()
  294. assert (
  295. module.execute_dump_command(
  296. database={'name': 'foo', 'options': '--stuff=such'},
  297. dump_path=flexmock(),
  298. database_names=('foo',),
  299. extra_environment=None,
  300. dry_run=False,
  301. dry_run_label='',
  302. )
  303. == process
  304. )
  305. def test_execute_dump_command_runs_non_default_mysqldump():
  306. process = flexmock()
  307. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  308. flexmock(module.os.path).should_receive('exists').and_return(False)
  309. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  310. flexmock(module).should_receive('execute_command').with_args(
  311. (
  312. 'custom_mysqldump', # Custom MySQL dump command
  313. '--add-drop-database',
  314. '--databases',
  315. 'foo',
  316. '--result-file',
  317. 'dump',
  318. ),
  319. extra_environment=None,
  320. run_to_completion=False,
  321. ).and_return(process).once()
  322. assert (
  323. module.execute_dump_command(
  324. database={
  325. 'name': 'foo',
  326. 'mysql_dump_command': 'custom_mysqldump',
  327. }, # Custom MySQL dump command specified
  328. dump_path=flexmock(),
  329. database_names=('foo',),
  330. extra_environment=None,
  331. dry_run=False,
  332. dry_run_label='',
  333. )
  334. == process
  335. )
  336. def test_execute_dump_command_with_duplicate_dump_skips_mysqldump():
  337. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  338. flexmock(module.os.path).should_receive('exists').and_return(True)
  339. flexmock(module.dump).should_receive('create_named_pipe_for_dump').never()
  340. flexmock(module).should_receive('execute_command').never()
  341. assert (
  342. module.execute_dump_command(
  343. database={'name': 'foo'},
  344. dump_path=flexmock(),
  345. database_names=('foo',),
  346. extra_environment=None,
  347. dry_run=True,
  348. dry_run_label='SO DRY',
  349. )
  350. is None
  351. )
  352. def test_execute_dump_command_with_dry_run_skips_mysqldump():
  353. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  354. flexmock(module.os.path).should_receive('exists').and_return(False)
  355. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  356. flexmock(module).should_receive('execute_command').never()
  357. assert (
  358. module.execute_dump_command(
  359. database={'name': 'foo'},
  360. dump_path=flexmock(),
  361. database_names=('foo',),
  362. extra_environment=None,
  363. dry_run=True,
  364. dry_run_label='SO DRY',
  365. )
  366. is None
  367. )
  368. def test_dump_data_sources_errors_for_missing_all_databases():
  369. databases = [{'name': 'all'}]
  370. flexmock(module).should_receive('make_dump_path').and_return('')
  371. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return(
  372. 'databases/localhost/all'
  373. )
  374. flexmock(module).should_receive('database_names_to_dump').and_return(())
  375. with pytest.raises(ValueError):
  376. assert module.dump_data_sources(
  377. databases,
  378. {},
  379. config_paths=('test.yaml',),
  380. borgmatic_runtime_directory='/run/borgmatic',
  381. patterns=[],
  382. dry_run=False,
  383. )
  384. def test_dump_data_sources_does_not_error_for_missing_all_databases_with_dry_run():
  385. databases = [{'name': 'all'}]
  386. flexmock(module).should_receive('make_dump_path').and_return('')
  387. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return(
  388. 'databases/localhost/all'
  389. )
  390. flexmock(module).should_receive('database_names_to_dump').and_return(())
  391. assert (
  392. module.dump_data_sources(
  393. databases,
  394. {},
  395. config_paths=('test.yaml',),
  396. borgmatic_runtime_directory='/run/borgmatic',
  397. patterns=[],
  398. dry_run=True,
  399. )
  400. == []
  401. )
  402. def test_restore_data_source_dump_runs_mysql_to_restore():
  403. hook_config = [{'name': 'foo'}, {'name': 'bar'}]
  404. extract_process = flexmock(stdout=flexmock())
  405. flexmock(module).should_receive('execute_command_with_processes').with_args(
  406. ('mysql', '--batch'),
  407. processes=[extract_process],
  408. output_log_level=logging.DEBUG,
  409. input_file=extract_process.stdout,
  410. extra_environment=None,
  411. ).once()
  412. module.restore_data_source_dump(
  413. hook_config,
  414. {},
  415. data_source={'name': 'foo'},
  416. dry_run=False,
  417. extract_process=extract_process,
  418. connection_params={
  419. 'hostname': None,
  420. 'port': None,
  421. 'username': None,
  422. 'password': None,
  423. },
  424. borgmatic_runtime_directory='/run/borgmatic',
  425. )
  426. def test_restore_data_source_dump_runs_mysql_with_options():
  427. hook_config = [{'name': 'foo', 'restore_options': '--harder'}]
  428. extract_process = flexmock(stdout=flexmock())
  429. flexmock(module).should_receive('execute_command_with_processes').with_args(
  430. ('mysql', '--batch', '--harder'),
  431. processes=[extract_process],
  432. output_log_level=logging.DEBUG,
  433. input_file=extract_process.stdout,
  434. extra_environment=None,
  435. ).once()
  436. module.restore_data_source_dump(
  437. hook_config,
  438. {},
  439. data_source=hook_config[0],
  440. dry_run=False,
  441. extract_process=extract_process,
  442. connection_params={
  443. 'hostname': None,
  444. 'port': None,
  445. 'username': None,
  446. 'password': None,
  447. },
  448. borgmatic_runtime_directory='/run/borgmatic',
  449. )
  450. def test_restore_data_source_dump_runs_non_default_mysql_with_options():
  451. hook_config = [{'name': 'foo', 'mysql_command': 'custom_mysql', 'restore_options': '--harder'}]
  452. extract_process = flexmock(stdout=flexmock())
  453. flexmock(module).should_receive('execute_command_with_processes').with_args(
  454. ('custom_mysql', '--batch', '--harder'),
  455. processes=[extract_process],
  456. output_log_level=logging.DEBUG,
  457. input_file=extract_process.stdout,
  458. extra_environment=None,
  459. ).once()
  460. module.restore_data_source_dump(
  461. hook_config,
  462. {},
  463. data_source=hook_config[0],
  464. dry_run=False,
  465. extract_process=extract_process,
  466. connection_params={
  467. 'hostname': None,
  468. 'port': None,
  469. 'username': None,
  470. 'password': None,
  471. },
  472. borgmatic_runtime_directory='/run/borgmatic',
  473. )
  474. def test_restore_data_source_dump_runs_mysql_with_hostname_and_port():
  475. hook_config = [{'name': 'foo', 'hostname': 'database.example.org', 'port': 5433}]
  476. extract_process = flexmock(stdout=flexmock())
  477. flexmock(module).should_receive('execute_command_with_processes').with_args(
  478. (
  479. 'mysql',
  480. '--batch',
  481. '--host',
  482. 'database.example.org',
  483. '--port',
  484. '5433',
  485. '--protocol',
  486. 'tcp',
  487. ),
  488. processes=[extract_process],
  489. output_log_level=logging.DEBUG,
  490. input_file=extract_process.stdout,
  491. extra_environment=None,
  492. ).once()
  493. module.restore_data_source_dump(
  494. hook_config,
  495. {},
  496. data_source=hook_config[0],
  497. dry_run=False,
  498. extract_process=extract_process,
  499. connection_params={
  500. 'hostname': None,
  501. 'port': None,
  502. 'username': None,
  503. 'password': None,
  504. },
  505. borgmatic_runtime_directory='/run/borgmatic',
  506. )
  507. def test_restore_data_source_dump_runs_mysql_with_username_and_password():
  508. hook_config = [{'name': 'foo', 'username': 'root', 'password': 'trustsome1'}]
  509. extract_process = flexmock(stdout=flexmock())
  510. flexmock(module).should_receive('execute_command_with_processes').with_args(
  511. ('mysql', '--batch', '--user', 'root'),
  512. processes=[extract_process],
  513. output_log_level=logging.DEBUG,
  514. input_file=extract_process.stdout,
  515. extra_environment={'MYSQL_PWD': 'trustsome1'},
  516. ).once()
  517. module.restore_data_source_dump(
  518. hook_config,
  519. {},
  520. data_source=hook_config[0],
  521. dry_run=False,
  522. extract_process=extract_process,
  523. connection_params={
  524. 'hostname': None,
  525. 'port': None,
  526. 'username': None,
  527. 'password': None,
  528. },
  529. borgmatic_runtime_directory='/run/borgmatic',
  530. )
  531. def test_restore_data_source_dump_with_connection_params_uses_connection_params_for_restore():
  532. hook_config = [
  533. {
  534. 'name': 'foo',
  535. 'username': 'root',
  536. 'password': 'trustsome1',
  537. 'restore_hostname': 'restorehost',
  538. 'restore_port': 'restoreport',
  539. 'restore_username': 'restoreusername',
  540. 'restore_password': 'restorepassword',
  541. }
  542. ]
  543. extract_process = flexmock(stdout=flexmock())
  544. flexmock(module).should_receive('execute_command_with_processes').with_args(
  545. (
  546. 'mysql',
  547. '--batch',
  548. '--host',
  549. 'clihost',
  550. '--port',
  551. 'cliport',
  552. '--protocol',
  553. 'tcp',
  554. '--user',
  555. 'cliusername',
  556. ),
  557. processes=[extract_process],
  558. output_log_level=logging.DEBUG,
  559. input_file=extract_process.stdout,
  560. extra_environment={'MYSQL_PWD': 'clipassword'},
  561. ).once()
  562. module.restore_data_source_dump(
  563. hook_config,
  564. {},
  565. data_source={'name': 'foo'},
  566. dry_run=False,
  567. extract_process=extract_process,
  568. connection_params={
  569. 'hostname': 'clihost',
  570. 'port': 'cliport',
  571. 'username': 'cliusername',
  572. 'password': 'clipassword',
  573. },
  574. borgmatic_runtime_directory='/run/borgmatic',
  575. )
  576. def test_restore_data_source_dump_without_connection_params_uses_restore_params_in_config_for_restore():
  577. hook_config = [
  578. {
  579. 'name': 'foo',
  580. 'username': 'root',
  581. 'password': 'trustsome1',
  582. 'hostname': 'dbhost',
  583. 'port': 'dbport',
  584. 'restore_username': 'restoreuser',
  585. 'restore_password': 'restorepass',
  586. 'restore_hostname': 'restorehost',
  587. 'restore_port': 'restoreport',
  588. }
  589. ]
  590. extract_process = flexmock(stdout=flexmock())
  591. flexmock(module).should_receive('execute_command_with_processes').with_args(
  592. (
  593. 'mysql',
  594. '--batch',
  595. '--host',
  596. 'restorehost',
  597. '--port',
  598. 'restoreport',
  599. '--protocol',
  600. 'tcp',
  601. '--user',
  602. 'restoreuser',
  603. ),
  604. processes=[extract_process],
  605. output_log_level=logging.DEBUG,
  606. input_file=extract_process.stdout,
  607. extra_environment={'MYSQL_PWD': 'restorepass'},
  608. ).once()
  609. module.restore_data_source_dump(
  610. hook_config,
  611. {},
  612. data_source=hook_config[0],
  613. dry_run=False,
  614. extract_process=extract_process,
  615. connection_params={
  616. 'hostname': None,
  617. 'port': None,
  618. 'username': None,
  619. 'password': None,
  620. },
  621. borgmatic_runtime_directory='/run/borgmatic',
  622. )
  623. def test_restore_data_source_dump_with_dry_run_skips_restore():
  624. hook_config = [{'name': 'foo'}]
  625. flexmock(module).should_receive('execute_command_with_processes').never()
  626. module.restore_data_source_dump(
  627. hook_config,
  628. {},
  629. data_source={'name': 'foo'},
  630. dry_run=True,
  631. extract_process=flexmock(),
  632. connection_params={
  633. 'hostname': None,
  634. 'port': None,
  635. 'username': None,
  636. 'password': None,
  637. },
  638. borgmatic_runtime_directory='/run/borgmatic',
  639. )