Esempio n. 1
0
def test_render_contributions_handles_unicode():
    hits = Response(
        Search(), {
            'hits': {
                'hits': [
                    {
                        '_type': 'hep',
                        '_source': {
                            'control_number':
                            1427573,
                            'titles': [
                                {
                                    'title':
                                    u'Storage Ring Based EDM Search — Achievements and Goals'
                                },
                            ],
                        },
                    },
                ],
                'total':
                1,
            },
        }).hits

    expected = ([
        [
            u"<a href='/literature/1427573'>Storage Ring Based EDM Search — Achievements and Goals</a>",
            u'\n\n',
            '',
            0,
        ],
    ], 1)
    result = render_contributions(hits)

    assert expected == result
def test_render_contributions_handles_unicode():
    hits = Response({
        'hits': {
            'hits': [
                {
                    '_type': 'hep',
                    '_source': {
                        'control_number': 1427573,
                        'titles': [
                            {'title': u'Storage Ring Based EDM Search — Achievements and Goals'},
                        ],
                    },
                },
            ],
            'total': 1,
        },
    }).hits

    expected = ([
        [
            u"<a href='/literature/1427573'>Storage Ring Based EDM Search — Achievements and Goals</a>",
            u'\n\n',
            '',
            0,
        ],
    ], 1)
    result = render_contributions(hits)

    assert expected == result
Esempio n. 3
0
def test_render_contributions():
    hits = Response(
        Search(), {
            'hits': {
                'hits': [
                    {
                        '_type': 'hep',
                        '_source': {
                            'citation_count':
                            1,
                            'control_number':
                            1,
                            'publication_info': [
                                {
                                    'journal_title': 'first-journal_title'
                                },
                            ],
                            'titles': [
                                {
                                    'title': 'first-title'
                                },
                            ],
                        },
                    },
                    {
                        '_type': 'hep',
                        '_source': {
                            'control_number': 2,
                            'titles': [
                                {
                                    'title': 'second-title'
                                },
                            ],
                        },
                    },
                ],
                'total':
                2,
            },
        }).hits

    expected = ([
        [
            "<a href='/literature/1'>first-title</a>",
            u'\n\n',
            'first-journal_title',
            1,
        ],
        [
            "<a href='/literature/2'>second-title</a>",
            u'\n\n',
            '',
            0,
        ],
    ], 2)
    result = render_contributions(hits)

    assert expected == result
def test_render_contributions():
    hits = Response(
        Search(),
        {
            'hits': {
                'hits': [
                    {
                        '_type': 'hep',
                        '_source': {
                            'citation_count': 1,
                            'control_number': 1,
                            'publication_info': [
                                {'journal_title': 'first-journal_title'},
                            ],
                            'titles': [
                                {'title': 'first-title'},
                            ],
                        },
                    },
                    {
                        '_type': 'hep',
                        '_source': {
                            'control_number': 2,
                            'titles': [
                                {'title': 'second-title'},
                            ],
                        },
                    },
                ],
                'total': 2,
            },
        }
    ).hits

    expected = ([
        [
            "<a href='/literature/1'>first-title</a>",
            u'\n\n',
            'first-journal_title',
            1,
        ],
        [
            "<a href='/literature/2'>second-title</a>",
            u'\n\n',
            '',
            0,
        ],
    ], 2)
    result = render_contributions(hits)

    assert expected == result