示例#1
0
def add_repo_section(context, parent_section):
    """
    add a repo section to the ostree section

    :type  context: pulp.client.extensions.core.ClientContext
    :param parent_section:  section of the CLI to which the repo section
                            should be added
    :type  parent_section:  pulp.client.extensions.extensions.PulpCliSection
    """
    repo_section = parent_section.create_subsection(SECTION_REPO, DESC_REPO)

    repo_section.add_command(CreateOSTreeRepositoryCommand(context))
    repo_section.add_command(UpdateOSTreeRepositoryCommand(context))
    repo_section.add_command(cudl.DeleteRepositoryCommand(context))
    repo_section.add_command(ListOSTreeRepositoriesCommand(context))
    repo_section.add_command(CopyCommand(context))
    repo_section.add_command(RemoveCommand(context))
    repo_section.add_command(SearchCommand(context))

    return repo_section
示例#2
0
    def test_run(self, transform):
        repo_id = 'test-repo'
        units = [1, 2, 3]
        documents = [str(u) for u in units]
        context = Mock()
        transform.side_effect = documents
        context.server.repo_unit.search.return_value = Mock(response_body=units)
        keywords = {'repo-id': repo_id, 'kw-1': 'v-1'}
        context.config = {
            'output': {'poll_frequency_in_seconds': 1}
        }

        # test
        command = SearchCommand(context)
        command.run(**keywords)

        # validation
        keywords.pop('repo-id')
        context.server.repo_unit.search.assert_called_once_with(repo_id, **keywords)
        context.prompt.render_title.assert_called_once_with(SearchCommand.TITLE)
        context.prompt.render_document_list.assert_called_once_with(
            documents, order=SearchCommand.ORDER)