示例#1
0
    def test_formatLanguages_no_counts(self, mocker):
        mockAggs = mocker.MagicMock()
        mockAggs.languages.languages.buckets = [
            mocker.MagicMock(key='bLang'),
            mocker.MagicMock(key='aLang')
        ]

        assert APIUtils.formatLanguages(mockAggs) ==\
            [{'language': 'aLang'}, {'language': 'bLang'}]
示例#2
0
    def test_formatLanguages_counts(self, mocker):
        mockAggs = mocker.MagicMock()
        mockAggs.languages.languages.buckets = [
            mocker.MagicMock(key='bLang',
                             work_totals=mocker.MagicMock(doc_count=10)),
            mocker.MagicMock(key='cLang',
                             work_totals=mocker.MagicMock(doc_count=30)),
            mocker.MagicMock(key='aLang',
                             work_totals=mocker.MagicMock(doc_count=20))
        ]

        assert APIUtils.formatLanguages(mockAggs, True) == [{
            'language': 'cLang',
            'work_total': 30
        }, {
            'language': 'aLang',
            'work_total': 20
        }, {
            'language': 'bLang',
            'work_total': 10
        }]