Fixing tests broken by excludes merging.
This commit is contained in:
parent
fea97b5149
commit
338b80903c
1 changed files with 23 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
|||
from collections import defaultdict, OrderedDict, namedtuple
|
||||
|
||||
from flexmock import flexmock
|
||||
|
||||
from borgmatic.config import convert as module
|
||||
|
||||
|
||||
|
@ -7,18 +9,27 @@ Parsed_config = namedtuple('Parsed_config', ('location', 'storage', 'retention',
|
|||
|
||||
|
||||
def test_convert_legacy_parsed_config_transforms_source_config_to_mapping():
|
||||
flexmock(module.yaml.comments).should_receive('CommentedMap').replace_with(OrderedDict)
|
||||
source_config = Parsed_config(
|
||||
location=OrderedDict([('source_directories', '/home'), ('repository', 'hostname.borg')]),
|
||||
storage=OrderedDict([('encryption_passphrase', 'supersecret')]),
|
||||
retention=OrderedDict([('keep_daily', 7)]),
|
||||
consistency=OrderedDict([('checks', 'repository')]),
|
||||
)
|
||||
source_excludes = ['/var']
|
||||
schema = {'map': defaultdict(lambda: {'map': {}})}
|
||||
|
||||
destination_config = module.convert_legacy_parsed_config(source_config, schema)
|
||||
destination_config = module.convert_legacy_parsed_config(source_config, source_excludes, schema)
|
||||
|
||||
assert destination_config == OrderedDict([
|
||||
('location', OrderedDict([('source_directories', ['/home']), ('repository', 'hostname.borg')])),
|
||||
(
|
||||
'location',
|
||||
OrderedDict([
|
||||
('source_directories', ['/home']),
|
||||
('repository', 'hostname.borg'),
|
||||
('exclude_patterns', ['/var']),
|
||||
]),
|
||||
),
|
||||
('storage', OrderedDict([('encryption_passphrase', 'supersecret')])),
|
||||
('retention', OrderedDict([('keep_daily', 7)])),
|
||||
('consistency', OrderedDict([('checks', ['repository'])])),
|
||||
|
@ -26,18 +37,26 @@ def test_convert_legacy_parsed_config_transforms_source_config_to_mapping():
|
|||
|
||||
|
||||
def test_convert_legacy_parsed_config_splits_space_separated_values():
|
||||
flexmock(module.yaml.comments).should_receive('CommentedMap').replace_with(OrderedDict)
|
||||
source_config = Parsed_config(
|
||||
location=OrderedDict([('source_directories', '/home /etc')]),
|
||||
storage=OrderedDict(),
|
||||
retention=OrderedDict(),
|
||||
consistency=OrderedDict([('checks', 'repository archives')]),
|
||||
)
|
||||
source_excludes = ['/var']
|
||||
schema = {'map': defaultdict(lambda: {'map': {}})}
|
||||
|
||||
destination_config = module.convert_legacy_parsed_config(source_config, schema)
|
||||
destination_config = module.convert_legacy_parsed_config(source_config, source_excludes, schema)
|
||||
|
||||
assert destination_config == OrderedDict([
|
||||
('location', OrderedDict([('source_directories', ['/home', '/etc'])])),
|
||||
(
|
||||
'location',
|
||||
OrderedDict([
|
||||
('source_directories', ['/home', '/etc']),
|
||||
('exclude_patterns', ['/var']),
|
||||
]),
|
||||
),
|
||||
('storage', OrderedDict()),
|
||||
('retention', OrderedDict()),
|
||||
('consistency', OrderedDict([('checks', ['repository', 'archives'])])),
|
||||
|
|
Loading…
Reference in a new issue