Beispiel #1
0
    def test_article_detail(self):
        """
        Teste da ``view function`` ``article_detail``, deve retornar uma página
        que usa o template ``article/detail.html``.
        """
        with current_app.app_context():

            collection = utils.makeOneCollection()

            resource = utils.makeOneResource()

            journal = utils.makeOneJournal()

            issue = utils.makeOneIssue({'journal': journal})

            article = utils.makeOneArticle({'title': 'Article Y',
                                            'htmls': [resource],
                                            'issue': issue,
                                            'journal': journal,
                                            'url_segment': '10-11'})

            response = self.client.get(url_for('main.article_detail',
                                               url_seg=journal.url_segment,
                                               url_seg_issue=issue.url_segment,
                                               url_seg_article=article.url_segment,
                                               lang_code='pt'))

            self.assertStatus(response, 200)
            self.assertTemplateUsed('article/detail.html')
            self.assertEqual(self.get_context_variable('article').id, article.id)
            self.assertEqual(self.get_context_variable('journal').id, article.journal.id)
            self.assertEqual(self.get_context_variable('issue').id, article.issue.id)
    def test_journal_open_access_in_issue_grid(self):
        """
        Testa se os links e o conteúdo da licença este de acordo com a licença
        cadastrado no periódico.
        """

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

            journal = utils.makeOneJournal()

            issue = utils.makeOneIssue({'journal': journal})

            with self.client as c:

                response = c.get(url_for('main.issue_grid',
                                         url_seg=journal.url_segment))

                self.assertStatus(response, 200)

                self.assertTemplateUsed('issue/grid.html')

                self.assertIn('/static/img/oa_logo_32.png', response.data)
                self.assertIn('href="%s"' % url_for('main.open_access'), response.data)
                self.assertIn('Open Access', response.data)
Beispiel #3
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'))
    def test_journal_without_social_networks_show_no_links(self):
        """
        COM:
            - Periódico sem redes socials
        QUANDO:
            - Acessarmos a home do periódico
        VERIFICAMOS:
            - Que não aparece a seção de redes sociais
            - O div com class="journalLinks" deve aparecer
        """

        with current_app.app_context():
            # with
            collection = utils.makeOneCollection()
            journal = utils.makeOneJournal({'collection': collection})
            with self.client as c:
                # when
                response = c.get(url_for('main.journal_detail', url_seg=journal.url_segment))
                # then
                self.assertEqual(journal.social_networks, [])
                self.assertStatus(response, 200)
                social_networks_class = u"journalLinks"
                self.assertIn(social_networks_class, response.data.decode('utf-8'))
                twitter_btn_class = u"bigTwitter"
                self.assertNotIn(twitter_btn_class, response.data.decode('utf-8'))
                facebook_btn_class = u"bigFacebook"
                self.assertNotIn(facebook_btn_class, response.data.decode('utf-8'))
                google_btn_class = u"bigGooglePlus"
                self.assertNotIn(google_btn_class, response.data.decode('utf-8'))
Beispiel #5
0
    def test_collection_sponsors_at_homepage(self):
        """
        acessar na homepage deve mostrar os sponsors no rodapé
        """
        # with
        with current_app.app_context():
            collection = utils.makeOneCollection()
            sponsor1 = utils.makeOneSponsor({'name': 'spo1', 'url': 'http://sponsor1.com', 'logo_url': 'http://sponsor1.com/logo1.png'})
            sponsor2 = utils.makeOneSponsor({'name': 'spo2', 'url': 'http://sponsor2.com', 'logo_url': 'http://sponsor2.com/logo1.png'})
            sponsor3 = utils.makeOneSponsor({'name': 'spo3', 'url': 'http://sponsor2.com', 'logo_url': 'http://sponsor2.com/logo1.png'})
            collection.sponsors = [
                sponsor1,
                sponsor2,
                sponsor3,
            ]
            collection.save()
            # when
            response = self.client.get(url_for('main.index'))
            # then
            self.assertStatus(response, 200)
            self.assertIn('<div class="partners">', response.data.decode('utf-8'))

            for sponsor in [sponsor1, sponsor2, sponsor3]:
                self.assertIn(sponsor.name, response.data.decode('utf-8'))
                self.assertIn(sponsor.url, response.data.decode('utf-8'))
                self.assertIn(sponsor.logo_url, response.data.decode('utf-8'))
    def test_journal_detail_mission_with_EN_language(self):
        """
        Teste para verificar se na interface inicial da revista esta retornando
        o texto no idioma Inglês.
        """
        journal = utils.makeOneJournal()

        with self.client as c:
            # Criando uma coleção para termos o objeto ``g`` na interface
            collection = utils.makeOneCollection()

            header = {'Referer': url_for('main.journal_detail',
                                         url_seg=journal.url_segment)}

            response = c.get(url_for('main.set_locale',
                                     lang_code='en'),
                                     headers=header,
                                     follow_redirects=True)

            self.assertEqual(200, response.status_code)

            self.assertEqual(flask.session['lang'], 'en')

            self.assertIn(u"This journal is aiming xpto",
                          response.data.decode('utf-8'))
Beispiel #7
0
    def test_the_title_of_the_article_list_without_unknow_language_for_article(self):
        """
        Teste para verificar se a interface do TOC esta retornando o título no
        idioma original quando não conhece o idioma.
        """
        journal = utils.makeOneJournal()

        with self.client as c:
            # Criando uma coleção para termos o objeto ``g`` na interface
            collection = utils.makeOneCollection()

            issue = utils.makeOneIssue({"journal": journal})

            translated_titles = []

            article = utils.makeOneArticle(
                {"issue": issue, "title": "Article Y", "translated_titles": translated_titles}
            )

            header = {
                "Referer": url_for("main.issue_toc", url_seg=journal.url_segment, url_seg_issue=issue.url_segment)
            }

            response = c.get(url_for("main.set_locale", lang_code="es_MX"), headers=header, follow_redirects=True)

            self.assertEqual(200, response.status_code)

            self.assertEqual(flask.session["lang"], "es_MX")

            self.assertIn(u"Article Y", response.data.decode("utf-8"))
Beispiel #8
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'))
Beispiel #9
0
    def test_the_title_of_the_article_list_when_language_EN(self):
        """
        Teste para verificar se a interface do TOC esta retornando o título no
        idioma Inglês.
        """
        journal = utils.makeOneJournal()

        with self.client as c:
            # Criando uma coleção para termos o objeto ``g`` na interface
            collection = utils.makeOneCollection()

            issue = utils.makeOneIssue({"journal": journal})

            translated_titles = [
                {"name": "Artigo Com Título Em Português", "language": "pt"},
                {"name": "Título Del Artículo En Portugués", "language": "es"},
                {"name": "Article Title In Portuguese", "language": "en"},
            ]

            article = utils.makeOneArticle(
                {"issue": issue, "title": "Article Y", "translated_titles": translated_titles}
            )

            header = {
                "Referer": url_for("main.issue_toc", url_seg=journal.url_segment, url_seg_issue=issue.url_segment)
            }

            response = c.get(url_for("main.set_locale", lang_code="en"), headers=header, follow_redirects=True)

            self.assertEqual(200, response.status_code)

            self.assertEqual(flask.session["lang"], "en")

            self.assertIn(u"Article Title In Portuguese", response.data.decode("utf-8"))
Beispiel #10
0
    def test_collection_list_institution(self):
        """
        Teste para a ``view function`` collection_list_institution, será avaliado
        somente o template utilizado pois essa função depende de definição do atributo
        instituição no manager.
        """

        collecton = utils.makeOneCollection()
        warnings.warn("Necessário definir o atributo instituição no modelo do Manager")

        response = self.client.get(url_for('main.collection_list') + '#publisher')

        self.assertStatus(response, 200)
        self.assertTemplateUsed('collection/list_journal.html')
Beispiel #11
0
    def test_collection_list_feed_without_journals(self):
        """
        Teste para avaliar o retorno da ``view function`` collection_list_feed
        quando não existe periódicos cadastrados deve retorna a msg
        ``Nenhum periódico encontrado`` no corpo da resposta.
        """
        with current_app.app_context():

            collection = utils.makeOneCollection()

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

            self.assertStatus(response, 200)
            self.assertIn(u'Nenhum periódico encontrado',
                          response.data.decode('utf-8'))
Beispiel #12
0
    def test_collection_list_institution_without_journals(self):
        """
        Teste para avaliar o retorno da ``view function`` collection_list_institution
        quando não existe periódicos cadastrados deve retorna a msg
        ``Nenhum periódico encontrado`` no corpo da resposta.
        """

        collecton = utils.makeOneCollection()
        response = self.client.get(url_for('main.collection_list'))

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

        self.assertIn(u'Nenhum periódico encontrado',
                      response.data.decode('utf-8'))
Beispiel #13
0
 def test_collection_address_at_journal_list_page_footer(self):
     """
     acessar na pagina Alfabética deve mostrar o endereço da coleção
     """
     # with
     with current_app.app_context():
         collection_data = {
             'address1': 'foo address',
             'address2': 'foo address',
         }
         collection = utils.makeOneCollection(attrib=collection_data)
         # when
         response = self.client.get(url_for('main.collection_list'))
         # then
         self.assertStatus(response, 200)
         self.assertIn(collection['address1'], response.data.decode('utf-8'))
         self.assertIn(collection['address2'], response.data.decode('utf-8'))
Beispiel #14
0
    def test_collection_open_access_list_theme(self):
        """
        Testa se os links e o conteúdo da licença esta de acordo com a licença
        cadastrada na coleção.
        """
        with current_app.app_context():
            collection = utils.makeOneCollection()

            with self.client as c:

                response = c.get(url_for('main.collection_list'))
                self.assertStatus(response, 200)

                self.assertTemplateUsed('collection/list_journal.html')

                self.assertIn('/static/img/oa_logo_32.png', response.data)
                self.assertIn('href="%s"' % url_for('main.open_access'), response.data)
                self.assertIn('Open Access', response.data)
    def test_journal_with_googleplus_social_networks_show_links(self):
        """
        COM:
            - Periódico COM redes socials
        QUANDO:
            - Acessarmos a home do periódico
        VERIFICAMOS:
            - Que SIM aparece a seção de redes sociais
            - O div com class="journalLinks" deve aparecer
        """

        with current_app.app_context():
            # with
            collection = utils.makeOneCollection()
            journal_data = {
                'collection': collection,
                'social_networks': [
                    {
                        'network': u'google',
                        'account': u'http://plus.google.com/+foo'
                    }
                ]
            }
            journal = utils.makeOneJournal(journal_data)
            with self.client as c:
                # when
                response = c.get(url_for('main.journal_detail', url_seg=journal.url_segment))
                # then
                self.assertStatus(response, 200)
                social_networks_class = u"journalLinks"
                self.assertIn(social_networks_class, response.data.decode('utf-8'))
                twitter_btn_class = u"bigTwitter"
                self.assertNotIn(twitter_btn_class, response.data.decode('utf-8'))
                facebook_btn_class = u"bigFacebook"
                self.assertNotIn(facebook_btn_class, response.data.decode('utf-8'))
                google_btn_class = u"bigGooglePlus"
                self.assertIn(google_btn_class, response.data.decode('utf-8'))

                expected_social_link = u'<a href="{account}" data-toggle="tooltip" title="{network}">'.format(
                    account=journal_data['social_networks'][0]['account'],
                    network=journal_data['social_networks'][0]['network'].title(),
                )
                self.assertIn(expected_social_link, response.data.decode('utf-8'))
Beispiel #16
0
    def test_collection_list_feed_without_issues(self):
        """
        Teste para verificar a reposta da ``view funciton``collection_list_feed
        Se cadastra 10 periódicos sem fascículo, 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)

            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'))
Beispiel #17
0
    def test_journal_detail(self):
        """
        Teste da ``view function`` ``journal_detail``, deve retornar uma página
        que usa o template ``journal/detail.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'})

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

            self.assertTrue(200, response.status_code)
            self.assertTemplateUsed('journal/detail.html')
            self.assertIn(u'Revista X',
                          response.data.decode('utf-8'))
            self.assertEqual(self.get_context_variable('journal').id, journal.id)
Beispiel #18
0
    def test_collection_list_alpha(self):
        """
        Teste para avaliar o retorno da ``view function`` collection_list_alpha,
        ao cadastrarmos 10 periódico a interface deve retornar uma listagem
        contendo elementos esperado também deve retornar o template
        ``collection/list_alpha.html``.
        """
        collecton = utils.makeOneCollection()
        journals = utils.makeAnyJournal(items=10)

        response = self.client.get(url_for('main.collection_list') + '#alpha')

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

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

        self.assertListEqual(sorted([journal.id for journal in journals]),
                             sorted([journal.id for journal in self.get_context_variable('journals')]))
Beispiel #19
0
    def test_issue_grid_without_issues(self):
        """
        Teste para avaliar o retorno da ``view function`` ``issue_grid``
        quando não existe fascículo cadastrado deve retornar ``status_code`` 200
        e a msg ``Nenhum fascículo encontrado para esse perióico``
        """

        with current_app.app_context():

            collection = utils.makeOneCollection()

            journal = utils.makeOneJournal()

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

            self.assertStatus(response, 200)
            self.assertTemplateUsed('issue/grid.html')

            self.assertIn(u'Nenhum fascículo encontrado para esse perióico',
                          response.data.decode('utf-8'))
Beispiel #20
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')
Beispiel #21
0
    def test_g_object_has_collection_object(self):
        """
        COM:
            - uma nova collection criada com o mesmo acronimo da setting: OPAC_CONFIG
        QUANDO:
            - solicitamo uma pagina
        VERIFICAMOS:
            - que no contexto, a variável 'g' tenha asociado uma instancia da collection
        """

        with current_app.app_context():
            # with
            collection_db_record = utils.makeOneCollection()

            # when
            with self.client as c:
                response = self.client.get(url_for('main.index'))
                # then
                self.assertStatus(response, 200)
                self.assertTrue(hasattr(g, 'collection'))
                g_collection = g.get('collection')
                self.assertEqual(g_collection._id, collection_db_record._id)
Beispiel #22
0
    def test_collection_list_theme(self):
        """
        Teste para avaliar o retorno da ``view function`` collection_list_theme
        ao cadastrarmos 60 periódico a interface deve retornar uma listagem
        contendo elementos esperado tambémdeve retornar o template
        ``collection/list_theme.html``.
        """

        collecton = utils.makeOneCollection()
        journals = utils.makeAnyJournal(items=30,
                                        attrib={"study_areas": ["Engineering"]})
        journals = utils.makeAnyJournal(items=30,
                                        attrib={"study_areas": ["Human Sciences",
                                                "Biological Sciences", "Engineering"]})

        response = self.client.get(url_for('main.collection_list') + '#theme')

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

        for journal in journals:
            self.assertIn('journals/%s' % journal.id,
                          response.data.decode('utf-8'))
Beispiel #23
0
    def test_issue_grid(self):
        """
        Teste da ``view function`` ``issue_grid`` acessando a grade de fascículos
        de um periódico, nesse teste deve ser retornado todos os fascículos com
        o atributo is_public=True de um fascículo, sendo que o template deve ser
        ``issue/grid.html``.
        """

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

            journal = utils.makeOneJournal()

            issues = utils.makeAnyIssue(attrib={'journal': journal.id})

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

            self.assertStatus(response, 200)
            self.assertTemplateUsed('issue/grid.html')

            for issue in issues:
                self.assertIn('/journal_acron', response.data.decode('utf-8'))
Beispiel #24
0
    def test_issue_toc(self):
        """
        Teste da ``view function`` ``issue_toc`` acessando a página do fascículo,
        deve retorna status_code 200 e o template ``issue/toc.html``.
        """

        with current_app.app_context():

            collection = utils.makeOneCollection()

            journal = utils.makeOneJournal()

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

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

            self.assertStatus(response, 200)
            self.assertTemplateUsed('issue/toc.html')
            # self.assertIn(u'Vol. 10 No. 31', response.data.decode('utf-8'))
            self.assertEqual(self.get_context_variable('issue').id, issue.id)
Beispiel #25
0
 def test_get_current_collection(self):
     collection = utils.makeOneCollection()
     controller_col = controllers.get_current_collection()
     self.assertEqual(collection, controller_col)