Exemplo n.º 1
0
 def test_get_selected_repositories_exits_on_no_selection(self, mock_exit):
     # Given
     selected_repositories = ()
     selected_groups = ()
     mock_exit.side_effect = Exception
     # When
     try:
         get_selected_repositories(selected_repositories, selected_groups)
     except:
         pass
     # Then
     mock_exit.assert_called_once_with(1, 'No repositories/groups provided')
Exemplo n.º 2
0
def main(ctx, repository, group, import_config):
    ctx.ensure_object(dict)

    repositories = tuple(map(lambda x: x.lstrip(" ="), repository))
    groups = tuple(map(lambda x: x.lstrip(" ="), group))

    ctx.obj[SELECTED_REPOSITORIES] = get_selected_repositories(
        repositories, groups)
Exemplo n.º 3
0
 def test_get_selected_repositories_exits_on_no_repositories_selected(
         self, mock_load_config, mock_exit):
     # Given
     selected_groups = (GROUP_NAMES[0], )
     mock_load_config.return_value = dict({
         'repositories':
         CONFIG_REPOSITORIES,
         'groups':
         dict({
             GROUP_NAMES[0]: dict({'repositories': dict({})}),
         })
     })
     mock_exit.side_effect = Exception
     # When
     try:
         get_selected_repositories((), selected_groups)
     except:
         pass
     # Then
     mock_exit.assert_called_once_with(1, 'No repositories selected')
Exemplo n.º 4
0
 def test_get_selected_repositories_exits_on_group_not_found(
         self, mock_load_config, mock_exit):
     # Given
     selected_groups = (GROUP_NAMES[1], )
     mock_load_config.return_value = dict({
         'repositories':
         CONFIG_REPOSITORIES,
         'groups':
         dict({
             GROUP_NAMES[0]: CONFIG_GROUPS[GROUP_NAMES[0]],
             GROUP_NAMES[2]: CONFIG_GROUPS[GROUP_NAMES[2]]
         })
     })
     mock_exit.side_effect = Exception
     # When
     try:
         get_selected_repositories((), selected_groups)
     except:
         pass
     # Then
     mock_exit.assert_called_once_with(
         1, 'Group "' + GROUP_NAMES[1] + '" not found in config')
Exemplo n.º 5
0
 def test_get_selected_repositories_exits_on_repository_not_found(
         self, mock_load_config, mock_exit):
     # Given
     selected_repositories = (REPOSITORY_NAMES[1], )
     mock_load_config.return_value = dict({
         'repositories':
         dict({
             REPOSITORY_NAMES[0]: CONFIG_REPOSITORIES[REPOSITORY_NAMES[0]],
             REPOSITORY_NAMES[2]: CONFIG_REPOSITORIES[REPOSITORY_NAMES[2]]
         }),
         'groups':
         CONFIG_REPOSITORIES
     })
     mock_exit.side_effect = Exception
     # When
     try:
         get_selected_repositories(selected_repositories, ())
     except:
         pass
     # Then
     mock_exit.assert_called_once_with(
         1, 'Repository "' + REPOSITORY_NAMES[1] + '" not found in config')
Exemplo n.º 6
0
 def test_get_selected_repositories_returns_selected_groups(
         self, mock_load_config):
     # Given
     selected_groups = (GROUP_NAMES[1], GROUP_NAMES[2])
     mock_load_config.return_value = dict({
         'repositories': CONFIG_REPOSITORIES,
         'groups': CONFIG_GROUPS
     })
     expected_repositories = dict({
         REPOSITORY_NAMES[0]:
         CONFIG_REPOSITORIES[REPOSITORY_NAMES[0]],
         REPOSITORY_NAMES[2]:
         CONFIG_REPOSITORIES[REPOSITORY_NAMES[2]]
     })
     # When
     actual_repositories = get_selected_repositories(
         tuple(), selected_groups)
     # Then
     mock_load_config.assert_called_once()
     self.assertEqual(expected_repositories, actual_repositories)