コード例 #1
0
ファイル: test_controller.py プロジェクト: ednilson/opac
    def test_get_journals_by_indexer(self):
        """
        Testando se o retorno da função controllers.get_journals_by_indexer()
        está de acordo com o esperado.
        """

        journal1 = self._makeOne({"index_at": ["SCIE"]})
        journal2 = self._makeOne({"index_at": ["SCIE", "SSCI"]})
        journal3 = self._makeOne({"index_at": ["SCIE"]})
        journal4 = self._makeOne({"index_at": ["SSCI", "ICSE"]})
        journal5 = self._makeOne({"index_at": ["SSCI", "SCIE"]})
        journal6 = self._makeOne({"index_at": ["SSCI"]})

        expected = {
                    'meta': {'total': 6},
                    'objects': {
                        u'SCIE': [journal1, journal2, journal3, journal5],
                        u'SSCI': [journal2, journal4, journal5],
                        u'ICSE': [journal4]
                    }
                }

        study_areas = controllers.get_journals_by_indexer()

        self.assertEqual(expected['meta']['total'], study_areas['meta']['total'])

        self.assertEqual(len(expected['objects']), len(study_areas['objects']))

        for area, journals in expected['objects'].iteritems():
            self.assertListEqual(sorted([journal.id for journal in expected['objects'][area]]),
                                 sorted([journal.id for journal in journals]))
コード例 #2
0
ファイル: views.py プロジェクト: ednilson/opac
def collection_list_theme():
    objects_by_area = controllers.get_journals_by_study_area()
    objects_by_indexer = controllers.get_journals_by_indexer()

    context = {
        'objects_by_area': objects_by_area,
        'objects_by_indexer': objects_by_indexer
    }

    return render_template("collection/list_theme.html", **context)
コード例 #3
0
ファイル: test_controller.py プロジェクト: ednilson/opac
    def test_get_journals_by_indexer_without_journal(self):
        """
        Testando controllers.test_get_journals_by_indexer() sem Journal.
        """
        expected = {
                    'meta': {'total': 0},
                    'objects': {}
                }

        study_areas = controllers.get_journals_by_indexer()

        self.assertEqual(expected['meta']['total'], study_areas['meta']['total'])

        self.assertEqual(len(expected['objects']), len(study_areas['objects']))