Esempio n. 1
0
    def test_collection_list_feed(self):
        """
        Teste para verificar a reposta da ``view funciton``collection_list_feed
        Se cadastra 10 periódicos, deve retornar na interface do rss, utilizando
        o template ``collection/list_feed_content.html```.
        """

        with current_app.app_context():

            collection = utils.makeOneCollection()
            journals = utils.makeAnyJournal(items=10)
            issues = []

            for journal in journals:
                issue = utils.makeOneIssue({'journal': journal.id})
                utils.makeAnyArticle(
                    issue=issue,
                    attrib={'journal': journal.id, 'issue': issue.id}
                )
                issues.append(issue)

            response = self.client.get(url_for('main.collection_list_feed'))

            self.assertStatus(response, 200)
            self.assertTemplateUsed('collection/list_feed_content.html')

            for journal in journals:
                self.assertIn('%s' % journal.url_segment,
                              response.data.decode('utf-8'))

            for issue in issues:
                self.assertIn('%s' % issue.url_segment,
                              response.data.decode('utf-8'))
Esempio n. 2
0
    def test_count_elements_by_type_and_visibility_type_article(self):
        """
        Testando a função count_elements_by_type_and_visibility() com 20
        artigos cadastrados, deve retornar apenas 20 artigos.
        """

        utils.makeAnyArticle(items=20)

        total_article = controllers.count_elements_by_type_and_visibility('article')

        self.assertEqual(total_article, 20)
Esempio n. 3
0
    def test_issue_feed(self):
        """
        Teste da ``view function`` ``issue_feed``, deve retornar um rss
        que usa o template ``issue/feed_content.html`` e o título do periódico no
        corpo da página.
        """

        with current_app.app_context():
            collection = utils.makeOneCollection()

            journal = utils.makeOneJournal()

            issue = utils.makeOneIssue({'number': '31',
                                        'volume': '10',
                                        'journal': journal})
            articles = utils.makeAnyArticle(
                issue=issue,
                attrib={'journal': issue.journal.id, 'issue': issue.id}
            )

            response = self.client.get(url_for('main.issue_feed',
                                       url_seg=journal.url_segment,
                                       url_seg_issue=issue.url_segment))

            self.assertStatus(response, 200)
            self.assertTemplateUsed('issue/feed_content.html')
            self.assertIn(u'Vol. 10 No. 31', response.data.decode('utf-8'))
Esempio n. 4
0
    def test_count_elements_by_type_and_visibility_article_public_only(self):
        """
        Testando a função count_elements_by_type_and_visibility() com 98
        artigos cadastrados com atributo puclic=true e 6 public=false,
        deve retornar apenas 20 artigo(somente os artigos marcados como
        publicos).
        """

        utils.makeAnyArticle(items=98)
        utils.makeOneArticle({'is_public': False})
        utils.makeOneArticle({'is_public': False})
        utils.makeOneArticle({'is_public': False})
        utils.makeOneArticle({'is_public': False})
        utils.makeOneArticle({'is_public': False})
        utils.makeOneArticle({'is_public': False})

        total_article = controllers.count_elements_by_type_and_visibility('article', public_only=True)

        self.assertEqual(total_article, 98)
Esempio n. 5
0
    def test_journal_feed(self):
        """
        Teste da ``view function`` ``journal_feed``, deve retornar um rss
        que usa o template ``issue/feed_content.html`` e o título do periódico no
        corpo da página.
        """

        with current_app.app_context():
            collection = utils.makeOneCollection()
            journal = utils.makeOneJournal({'title': 'Revista X'})
            issue = utils.makeOneIssue({'journal': journal})
            articles = utils.makeAnyArticle(
                issue=issue,
                attrib={'journal': journal.id, 'issue': issue.id}
            )

            response = self.client.get(url_for('main.journal_feed',
                                               url_seg=journal.url_segment))

            self.assertTrue(200, response.status_code)
            self.assertTemplateUsed('issue/feed_content.html')
Esempio n. 6
0
 def _makeAny(self, issue=None, items=3):
     """
     Retorna uma lista de objetos ``Article`` com atributos ``jid``,
     ``is_public`` e ``acronym`` limitando a quantidade pelo param ``items``.
     """
     return utils.makeAnyArticle(issue=issue, items=items)