Beispiel #1
0
def collection_list():
    allowed_filters = ["current", "no-current", ""]
    query_filter = request.args.get("status", "")

    if not query_filter in allowed_filters:
        query_filter = ""

    journals_list = [
        controllers.get_journal_json_data(journal)
        for journal in controllers.get_journals(query_filter=query_filter)
    ]

    return render_template(
        "collection/list_journal.html", **{
            'journals_list': journals_list,
            'query_filter': query_filter
        })
Beispiel #2
0
    def test_get_journals_grouped_by_study_area(self):
        """
        Testando se o retorno da função controllers.get_journals_by_study_area()
        está de acordo com o esperado.
        """

        journal1 = self._makeOne({
            "study_areas": ["Health Sciences"],
            "last_issue": {"volume": "1", "number": "1", "year": "2016"}
        })
        journal2 = self._makeOne({
            "study_areas": ["Health Sciences", "Biological Sciences"],
            "last_issue": {"volume": "2", "number": "2", "year": "2016"}
        })
        journal3 = self._makeOne({
            "study_areas": ["Exact and Earth Sciences"],
            "last_issue": {"volume": "3", "number": "3", "year": "2016"}
        })
        journal4 = self._makeOne({
            "study_areas": ["Human Sciences", "Biological Sciences", "Engineering"],
            "last_issue": {"volume": "4", "number": "4", "year": "2016"}
        })
        journal5 = self._makeOne({
            "study_areas": ["Linguistics"],
            "last_issue": {"volume": "5", "number": "5", "year": "2016"}
        })
        journal6 = self._makeOne({
            "study_areas": ["Engineering"],
            "last_issue": {"volume": "6", "number": "6", "year": "2016"}
        })

        expected = {
            'meta': {
                'total': 6,
                'themes_count': 6
            },
            'objects': {
                'Health Sciences': [
                    controllers.get_journal_json_data(journal1),
                    controllers.get_journal_json_data(journal2)
                ],
                'Engineering': [
                    controllers.get_journal_json_data(journal4),
                    controllers.get_journal_json_data(journal6)
                ],
                'Biological Sciences': [
                    controllers.get_journal_json_data(journal2),
                    controllers.get_journal_json_data(journal4)
                ],
                'Linguistics': [
                    controllers.get_journal_json_data(journal5)
                ],
                'Human Sciences': [
                    controllers.get_journal_json_data(journal4)
                ],
                'Exact and Earth Sciences': [
                    controllers.get_journal_json_data(journal3)
                ]
            }
        }

        grouped_objects = controllers.get_journals_grouped_by('study_areas')

        self.assertEqual(expected['meta']['total'], grouped_objects['meta']['total'])
        self.assertEqual(expected['meta']['themes_count'], grouped_objects['meta']['themes_count'])
        self.assertEqual(len(expected['objects']), len(grouped_objects['objects']))

        for grouper, journals in expected['objects'].items():
            self.assertListEqual(sorted([journal['id'] for journal in expected['objects'][grouper]]),
                                 sorted([journal['id'] for journal in journals]))
Beispiel #3
0
    def test_get_journals_grouped_by_publisher_name(self):
        """
        Testando se o retorno da função controllers.get_journals_grouped_by('publisher_name')
        está de acordo com o esperado.
        """

        journal1 = self._makeOne({
            "publisher_name": "CNPQ",
            "last_issue": {"volume": "1", "number": "1", "year": "2016"}
        })
        journal2 = self._makeOne({
            "publisher_name": "SciELO",
            "last_issue": {"volume": "2", "number": "2", "year": "2016"}
        })
        journal3 = self._makeOne({
            "publisher_name": "FAPESP",
            "last_issue": {"volume": "3", "number": "3", "year": "2016"}
        })
        journal4 = self._makeOne({
            "publisher_name": "FUNDAÇÃO XPTO",
            "last_issue": {"volume": "4", "number": "4", "year": "2016"}
        })
        journal5 = self._makeOne({
            "publisher_name": "FAPESP",
            "last_issue": {"volume": "5", "number": "5", "year": "2016"}
        })
        journal6 = self._makeOne({
            "publisher_name": "FUNDAÇÃO XPTO",
            "last_issue": {"volume": "6", "number": "6", "year": "2016"}
        })

        expected = {
            'meta': {
                'total': 6,
                'themes_count': 4
            },
            'objects': {
                'CNPQ': [
                    controllers.get_journal_json_data(journal1)
                ],
                'SciELO': [
                    controllers.get_journal_json_data(journal2),
                    controllers.get_journal_json_data(journal3),
                    controllers.get_journal_json_data(journal4),
                    controllers.get_journal_json_data(journal5)
                ],
                'FAPESP': [
                    controllers.get_journal_json_data(journal4)
                ],
                'FUNDAÇÃO XPTO': [
                    controllers.get_journal_json_data(journal4),
                    controllers.get_journal_json_data(journal6)
                ]
            }
        }

        grouped_objects = controllers.get_journals_grouped_by('publisher_name')

        self.assertEqual(expected['meta']['total'], grouped_objects['meta']['total'])
        self.assertEqual(expected['meta']['themes_count'], grouped_objects['meta']['themes_count'])
        self.assertEqual(len(expected['objects']), len(grouped_objects['objects']))

        for grouper, journals in expected['objects'].items():
            self.assertListEqual(sorted([journal['id'] for journal in expected['objects'][grouper]]),
                                 sorted([journal['id'] for journal in journals]))
Beispiel #4
0
    def test_get_journals_grouped_by_index_at(self):
        """
        Testando se o retorno da função controllers.get_journals_grouped_by('index_at')
        está de acordo com o esperado.
        """

        journal1 = self._makeOne({
            "index_at": ["SCIE"],
            "last_issue": {"volume": "1", "number": "1", "year": "2016"}
        })
        journal2 = self._makeOne({
            "index_at": ["SCIE", "SSCI"],
            "last_issue": {"volume": "2", "number": "2", "year": "2016"}
        })
        journal3 = self._makeOne({
            "index_at": ["SCIE"],
            "last_issue": {"volume": "3", "number": "3", "year": "2016"}
        })
        journal4 = self._makeOne({
            "index_at": ["SSCI", "ICSE"],
            "last_issue": {"volume": "4", "number": "4", "year": "2016"}
        })
        journal5 = self._makeOne({
            "index_at": ["SSCI", "SCIE"],
            "last_issue": {"volume": "5", "number": "5", "year": "2016"}
        })
        journal6 = self._makeOne({
            "index_at": ["SSCI"],
            "last_issue": {"volume": "6", "number": "6", "year": "2016"}
        })

        expected = {
            'meta': {
                'total': 6,
                'themes_count': 3
            },
            'objects': {
                'SCIE': [
                    controllers.get_journal_json_data(journal1),
                    controllers.get_journal_json_data(journal2),
                    controllers.get_journal_json_data(journal3),
                    controllers.get_journal_json_data(journal5)
                ],
                'SSCI': [
                    controllers.get_journal_json_data(journal2),
                    controllers.get_journal_json_data(journal4),
                    controllers.get_journal_json_data(journal5)
                ],
                'ICSE': [
                    controllers.get_journal_json_data(journal4)
                ]
            }
        }

        grouped_objects = controllers.get_journals_grouped_by('index_at')

        self.assertEqual(expected['meta']['total'], grouped_objects['meta']['total'])
        self.assertEqual(expected['meta']['themes_count'], grouped_objects['meta']['themes_count'])
        self.assertEqual(len(expected['objects']), len(grouped_objects['objects']))
        for grouper, journals in expected['objects'].items():
            self.assertListEqual(sorted([journal['id'] for journal in expected['objects'][grouper]]),
                                 sorted([journal['id'] for journal in journals]))
Beispiel #5
0
    def test_get_journals_grouped_by_study_area(self):
        """
        Testando se o retorno da função controllers.get_journals_by_study_area()
        está de acordo com o esperado.
        """

        journal1 = self._make_one({
            "study_areas": ["Health Sciences"],
            "last_issue": {"volume": "1", "number": "1", "year": "2016"}
        })
        journal2 = self._make_one({
            "study_areas": ["Health Sciences", "Biological Sciences"],
            "last_issue": {"volume": "2", "number": "2", "year": "2016"}
        })
        journal3 = self._make_one({
            "study_areas": ["Exact and Earth Sciences"],
            "last_issue": {"volume": "3", "number": "3", "year": "2016"}
        })
        journal4 = self._make_one({
            "study_areas": ["Human Sciences", "Biological Sciences", "Engineering"],
            "last_issue": {"volume": "4", "number": "4", "year": "2016"}
        })
        journal5 = self._make_one({
            "study_areas": ["Linguistics"],
            "last_issue": {"volume": "5", "number": "5", "year": "2016"}
        })
        journal6 = self._make_one({
            "study_areas": ["Engineering"],
            "last_issue": {"volume": "6", "number": "6", "year": "2016"}
        })

        expected = {
            'meta': {
                'total': 6,
                'themes_count': 6
            },
            'objects': {
                'Health Sciences': [
                    controllers.get_journal_json_data(journal1),
                    controllers.get_journal_json_data(journal2)
                ],
                'Engineering': [
                    controllers.get_journal_json_data(journal4),
                    controllers.get_journal_json_data(journal6)
                ],
                'Biological Sciences': [
                    controllers.get_journal_json_data(journal2),
                    controllers.get_journal_json_data(journal4)
                ],
                'Linguistics': [
                    controllers.get_journal_json_data(journal5)
                ],
                'Human Sciences': [
                    controllers.get_journal_json_data(journal4)
                ],
                'Exact and Earth Sciences': [
                    controllers.get_journal_json_data(journal3)
                ]
            }
        }

        grouped_objects = controllers.get_journals_grouped_by('study_areas')

        self.assertEqual(expected['meta']['total'], grouped_objects['meta']['total'])
        self.assertEqual(expected['meta']['themes_count'], grouped_objects['meta']['themes_count'])
        self.assertEqual(len(expected['objects']), len(grouped_objects['objects']))

        for grouper, journals in expected['objects'].items():
            self.assertListEqual(sorted([journal['id'] for journal in expected['objects'][grouper]]),
                                 sorted([journal['id'] for journal in journals]))
Beispiel #6
0
    def test_get_journals_grouped_by_publisher_name(self):
        """
        Testando se o retorno da função controllers.get_journals_grouped_by('publisher_name')
        está de acordo com o esperado.
        """

        journal1 = self._make_one({
            "publisher_name": "CNPQ",
            "last_issue": {"volume": "1", "number": "1", "year": "2016"}
        })
        journal2 = self._make_one({
            "publisher_name": "SciELO",
            "last_issue": {"volume": "2", "number": "2", "year": "2016"}
        })
        journal3 = self._make_one({
            "publisher_name": "FAPESP",
            "last_issue": {"volume": "3", "number": "3", "year": "2016"}
        })
        journal4 = self._make_one({
            "publisher_name": "FUNDAÇÃO XPTO",
            "last_issue": {"volume": "4", "number": "4", "year": "2016"}
        })
        journal5 = self._make_one({
            "publisher_name": "FAPESP",
            "last_issue": {"volume": "5", "number": "5", "year": "2016"}
        })
        journal6 = self._make_one({
            "publisher_name": "FUNDAÇÃO XPTO",
            "last_issue": {"volume": "6", "number": "6", "year": "2016"}
        })

        expected = {
            'meta': {
                'total': 6,
                'themes_count': 4
            },
            'objects': {
                'CNPQ': [
                    controllers.get_journal_json_data(journal1)
                ],
                'SciELO': [
                    controllers.get_journal_json_data(journal2),
                    controllers.get_journal_json_data(journal3),
                    controllers.get_journal_json_data(journal4),
                    controllers.get_journal_json_data(journal5)
                ],
                'FAPESP': [
                    controllers.get_journal_json_data(journal4)
                ],
                'FUNDAÇÃO XPTO': [
                    controllers.get_journal_json_data(journal4),
                    controllers.get_journal_json_data(journal6)
                ]
            }
        }

        grouped_objects = controllers.get_journals_grouped_by('publisher_name')

        self.assertEqual(expected['meta']['total'], grouped_objects['meta']['total'])
        self.assertEqual(expected['meta']['themes_count'], grouped_objects['meta']['themes_count'])
        self.assertEqual(len(expected['objects']), len(grouped_objects['objects']))

        for grouper, journals in expected['objects'].items():
            self.assertListEqual(sorted([journal['id'] for journal in expected['objects'][grouper]]),
                                 sorted([journal['id'] for journal in journals]))
Beispiel #7
0
    def test_get_journals_grouped_by_index_at(self):
        """
        Testando se o retorno da função controllers.get_journals_grouped_by('index_at')
        está de acordo com o esperado.
        """

        journal1 = self._make_one({
            "index_at": ["SCIE"],
            "last_issue": {"volume": "1", "number": "1", "year": "2016"}
        })
        journal2 = self._make_one({
            "index_at": ["SCIE", "SSCI"],
            "last_issue": {"volume": "2", "number": "2", "year": "2016"}
        })
        journal3 = self._make_one({
            "index_at": ["SCIE"],
            "last_issue": {"volume": "3", "number": "3", "year": "2016"}
        })
        journal4 = self._make_one({
            "index_at": ["SSCI", "ICSE"],
            "last_issue": {"volume": "4", "number": "4", "year": "2016"}
        })
        journal5 = self._make_one({
            "index_at": ["SSCI", "SCIE"],
            "last_issue": {"volume": "5", "number": "5", "year": "2016"}
        })
        self._make_one({
            "index_at": ["SSCI"],
            "last_issue": {"volume": "6", "number": "6", "year": "2016"}
        })

        expected = {
            'meta': {
                'total': 6,
                'themes_count': 3
            },
            'objects': {
                'SCIE': [
                    controllers.get_journal_json_data(journal1),
                    controllers.get_journal_json_data(journal2),
                    controllers.get_journal_json_data(journal3),
                    controllers.get_journal_json_data(journal5)
                ],
                'SSCI': [
                    controllers.get_journal_json_data(journal2),
                    controllers.get_journal_json_data(journal4),
                    controllers.get_journal_json_data(journal5)
                ],
                'ICSE': [
                    controllers.get_journal_json_data(journal4)
                ]
            }
        }

        grouped_objects = controllers.get_journals_grouped_by('index_at')

        self.assertEqual(expected['meta']['total'], grouped_objects['meta']['total'])
        self.assertEqual(expected['meta']['themes_count'], grouped_objects['meta']['themes_count'])
        self.assertEqual(len(expected['objects']), len(grouped_objects['objects']))
        for grouper, journals in expected['objects'].items():
            self.assertListEqual(sorted([journal['id'] for journal in expected['objects'][grouper]]),
                                 sorted([journal['id'] for journal in journals]))