2018-07-28 23:21:38 +02:00
|
|
|
import json
|
|
|
|
import sys
|
|
|
|
|
2018-07-29 00:02:17 +02:00
|
|
|
from flexmock import flexmock
|
|
|
|
|
|
|
|
from borgmatic.commands import borgmatic
|
|
|
|
|
2018-07-28 23:21:38 +02:00
|
|
|
|
|
|
|
def test__run_commands_handles_multiple_json_outputs_in_array():
|
2018-07-29 00:02:17 +02:00
|
|
|
(
|
|
|
|
flexmock(borgmatic)
|
|
|
|
.should_receive('_run_commands_on_repository')
|
|
|
|
.times(3)
|
|
|
|
.replace_with(
|
2018-09-30 07:45:00 +02:00
|
|
|
lambda args, consistency, json_results, local_path, location, remote_path, retention, storage, unexpanded_repository: json_results.append(
|
|
|
|
{"whatever": unexpanded_repository}
|
|
|
|
)
|
2018-07-29 00:02:17 +02:00
|
|
|
)
|
|
|
|
)
|
2018-07-28 23:21:38 +02:00
|
|
|
|
2018-07-29 00:02:17 +02:00
|
|
|
(
|
|
|
|
flexmock(sys.stdout)
|
|
|
|
.should_call("write")
|
|
|
|
.with_args(
|
|
|
|
json.dumps(
|
|
|
|
json.loads(
|
|
|
|
'''
|
|
|
|
[
|
|
|
|
{"whatever": "fake_repo1"},
|
|
|
|
{"whatever": "fake_repo2"},
|
|
|
|
{"whatever": "fake_repo3"}
|
|
|
|
]
|
2018-09-30 07:45:00 +02:00
|
|
|
'''
|
2018-07-29 00:02:17 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2018-07-28 23:21:38 +02:00
|
|
|
|
2018-07-29 00:02:17 +02:00
|
|
|
borgmatic._run_commands(
|
|
|
|
args=flexmock(json=True),
|
|
|
|
consistency=None,
|
|
|
|
local_path=None,
|
2018-09-30 07:45:00 +02:00
|
|
|
location={'repositories': ['fake_repo1', 'fake_repo2', 'fake_repo3']},
|
2018-07-29 00:02:17 +02:00
|
|
|
remote_path=None,
|
|
|
|
retention=None,
|
|
|
|
storage=None,
|
|
|
|
)
|