Пример #1
0
    def test_run_without_details(self):
        """
        Test the run() method without the details flag.
        """
        _packages = [{'metadata': 'package_1'}, {'metadata': 'package_2'}]

        def search(_repo_id, **_kwargs):
            """
            Fakes the server search.
            """
            self.assertEqual(_repo_id, 'some_repo')
            self.assertEqual(_kwargs,
                             {'type_ids': [constants.PACKAGE_TYPE_ID]})

            response = mock.MagicMock()
            response.response_body = _packages
            return response

        context = mock.MagicMock()
        context.server.repo_unit.search.side_effect = search
        c = packages.ListPackagesCommand(context)
        kwargs = {options.OPTION_REPO_ID.keyword: 'some_repo'}

        c.run(**kwargs)

        context.prompt.render_document_list.assert_called_once_with(
            ['package_1', 'package_2'], order=['name', 'version', 'author'])
Пример #2
0
    def test___init__(self, super___init__):
        """
        Assert correct behavior from __init__().
        """
        context = mock.MagicMock()

        c = packages.ListPackagesCommand(context)

        super___init__.assert_called_once_with(
            c.run, name='packages', description=packages.DESC_SEARCH)
        self.assertEqual(c.context, context)
Пример #3
0
def _add_repo_section(context, parent_section):
    """
    add a repo section to the python section

    :param context:         The client context
    :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(CreatePythonRepositoryCommand(context))
    repo_section.add_command(UpdatePythonRepositoryCommand(context))
    repo_section.add_command(cudl.DeleteRepositoryCommand(context))
    repo_section.add_command(ListPythonRepositoriesCommand(context))

    _add_publish_section(context, repo_section)
    _add_sync_section(context, repo_section)

    repo_section.add_command(upload.UploadPackageCommand(context))
    repo_section.add_command(packages.RemovePackagesCommand(context))
    repo_section.add_command(packages.CopyPackagesCommand(context))
    repo_section.add_command(packages.ListPackagesCommand(context))