2021-02-17 02:14:58 +00:00
|
|
|
import pytest
|
2024-10-18 11:08:59 +00:00
|
|
|
|
2018-11-30 00:40:18 +00:00
|
|
|
import vorta.borg
|
2021-11-17 09:14:11 +00:00
|
|
|
import vorta.store.models
|
2021-10-04 11:31:41 +00:00
|
|
|
from vorta.borg.prune import BorgPruneJob
|
2018-11-30 00:40:18 +00:00
|
|
|
|
|
|
|
|
2020-03-03 05:19:36 +00:00
|
|
|
def test_borg_prune(qapp, qtbot, mocker, borg_json_output):
|
2018-11-30 00:40:18 +00:00
|
|
|
stdout, stderr = borg_json_output('prune')
|
|
|
|
popen_result = mocker.MagicMock(stdout=stdout, stderr=stderr, returncode=0)
|
2021-10-04 11:31:41 +00:00
|
|
|
mocker.patch.object(vorta.borg.borg_job, 'Popen', return_value=popen_result)
|
2018-11-30 00:40:18 +00:00
|
|
|
|
2021-11-17 09:14:11 +00:00
|
|
|
params = BorgPruneJob.prepare(vorta.store.models.BackupProfileModel.select().first())
|
2021-10-04 11:31:41 +00:00
|
|
|
thread = BorgPruneJob(params['cmd'], params, qapp)
|
2018-11-30 00:40:18 +00:00
|
|
|
|
2021-02-17 02:14:58 +00:00
|
|
|
with qtbot.waitSignal(thread.result, **pytest._wait_defaults) as blocker:
|
2018-11-30 00:40:18 +00:00
|
|
|
blocker.connect(thread.updated)
|
|
|
|
thread.run()
|
|
|
|
|
|
|
|
assert blocker.args[0]['returncode'] == 0
|