Allow the "--repository" flag to match across multiple configuration files (#818).

This commit is contained in:
Dan Helfman 2024-01-21 18:25:44 -08:00
parent f9998b50e8
commit e9813d2539
4 changed files with 7 additions and 22 deletions

3
NEWS
View File

@ -1,3 +1,6 @@
1.8.8.dev0
* #818: Allow the "--repository" flag to match across multiple configuration files.
1.8.7
* #736: Store included configuration files within each backup archive in support of the "config
bootstrap" action. Previously, only top-level configuration files were stored.

View File

@ -167,11 +167,10 @@ def repositories_match(first, second):
def guard_configuration_contains_repository(repository, configurations):
'''
Given a repository path and a dict mapping from config filename to corresponding parsed config
dict, ensure that the repository is declared exactly once in all of the configurations. If no
dict, ensure that the repository is declared at least once in all of the configurations. If no
repository is given, skip this check.
Raise ValueError if the repository is not found in a configuration, or is declared multiple
times.
Raise ValueError if the repository is not found in any configurations.
'''
if not repository:
return
@ -186,9 +185,7 @@ def guard_configuration_contains_repository(repository, configurations):
)
if count == 0:
raise ValueError(f'Repository {repository} not found in configuration files')
if count > 1:
raise ValueError(f'Repository {repository} found in multiple configuration files')
raise ValueError(f'Repository "{repository}" not found in configuration files')
def guard_single_repository_selected(repository, configurations):

View File

@ -1,6 +1,6 @@
from setuptools import find_packages, setup
VERSION = '1.8.7'
VERSION = '1.8.8.dev0'
setup(

View File

@ -184,21 +184,6 @@ def test_guard_configuration_contains_repository_errors_when_repository_missing_
)
def test_guard_configuration_contains_repository_errors_when_repository_matches_config_twice():
flexmock(module).should_receive('repositories_match').replace_with(
lambda first, second: first == second
)
with pytest.raises(ValueError):
module.guard_configuration_contains_repository(
repository='repo',
configurations={
'config.yaml': {'repositories': ['repo', 'repo2']},
'other.yaml': {'repositories': ['repo']},
},
)
def test_guard_single_repository_selected_raises_when_multiple_repositories_configured_and_none_selected():
with pytest.raises(ValueError):
module.guard_single_repository_selected(