コード例 #1
0
    def test_transform(self):
        unit = {
            'unit_id': 0,
            'created': 1,
            'updated': 2,
            'metadata': {
                'remote_id': 3,
                'branch': 4,
                'commit': 5,
                'metadata': {'version': 6}
            }
        }

        # test
        document = SearchCommand.transform(unit)

        # validation
        self.assertEqual(
            document,
            {
                'id': 0,
                'created': 1,
                'updated': 2,
                'remote_id': 3,
                'branch': 4,
                'commit': 5,
                'version': 6
            })
コード例 #2
0
ファイル: test_unit.py プロジェクト: beav/pulp_ostree
    def test_transform(self):
        unit = {
            'id': 0,
            'created': 1,
            'updated': 2,
            'metadata': {
                'timestamp': 3,
                'remote_id': 4,
                'digest': 5,
                'refs': 6
            }
        }

        # test
        document = SearchCommand.transform(unit)

        # validation
        self.assertEqual(
            document,
            {
                'id': 0,
                'created': 1,
                'updated': 2,
                'timestamp': 3,
                'remote_id': 4,
                'digest': 5,
                'refs': 6
            })
コード例 #3
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)
コード例 #4
0
ファイル: pulp_cli.py プロジェクト: seandst/pulp_ostree
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