From c4b7795985566dacde10fd3cb71fc5b3c0c953fd Mon Sep 17 00:00:00 2001
From: Innolabs <86991526+gitnnolabs@users.noreply.github.com>
Date: Fri, 28 Jul 2023 15:19:35 -0300
Subject: [PATCH 1/2] Fix coding styles
---
opac/tests/test_main_views.py | 5339 +++++++++++++++++----------------
opac/webapp/controllers.py | 6 +
2 files changed, 2699 insertions(+), 2646 deletions(-)
diff --git a/opac/tests/test_main_views.py b/opac/tests/test_main_views.py
index fc5e42ba..fb48f0c5 100644
--- a/opac/tests/test_main_views.py
+++ b/opac/tests/test_main_views.py
@@ -15,2221 +15,2220 @@
from . import utils
from .base import BaseTestCase
+# class MainTestCase(BaseTestCase):
+# def test_home_page(self):
+# """
+# Teste da página inicial, deve retorna utf-8 como conjunto de caracter e
+# o template ``collection/index.html``.
+# """
+# with current_app.app_context():
+# utils.makeOneCollection()
+# with self.client as c:
+# response = c.get(url_for("main.index"))
+# self.assertStatus(response, 200)
+# self.assertEqual("text/html; charset=utf-8", response.content_type)
+# self.assert_template_used("collection/index.html")
+
+# def test_the_page_have_cache_control_max_age(self):
+# """
+# Teste da página inicial, verifica se existe o header Cache-Control: max-age=604800.
+# """
+
+# with current_app.app_context():
+# utils.makeOneCollection()
+# with self.client as c:
+# response = c.get(url_for("main.index"))
+# self.assertStatus(response, 200)
+# self.assertTrue(
+# response.cache_control.max_age,
+# current_app.config["CACHE_CONTROL_MAX_AGE_HEADER"],
+# )
+
+# def test_should_obtain_the_latest_metric_counts_from_collection(self):
+# with current_app.app_context():
+# collection = utils.makeOneCollection(
+# {
+# "metrics": {
+# "total_journal": 0,
+# "total_issue": 0,
+# "total_article": 0,
+# "total_citation": 0,
+# },
+# }
+# )
+
+# with self.client as client:
+# response = client.get(url_for("main.index"))
+# collection = g.get("collection")
+# self.assertEqual(0, collection.metrics.total_journal)
+
+# utils.makeOneJournal({"is_public": True, "current_status": "current"})
+# utils.makeOneArticle({"is_public": True})
+
+# with self.client as client:
+# response = client.get(url_for("main.index"))
+# self.assertEqual(0, collection.metrics.total_article)
+# self.assertEqual(0, collection.metrics.total_journal)
+
+# 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 = c.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)
+
+# def test_change_set_locale(self):
+# """
+# Teste para alterar o idioma da interface, nesse teste a URL:
+# '/set_locale/ Código de idioma inválido
Código de idioma inválido
" - - with self.client as c: - response = c.get(url_for("main.set_locale", lang_code="en_US")) - self.assertEqual(400, response.status_code) - self.assertIn("Código de idioma inválido", response.data.decode("utf-8")) - self.assertTemplateUsed("errors/400.html") - - self.assertEqual(expected_message, self.get_context_variable("message")) - - @unittest.skip("Revisar/Refazer, agora a lista é carregada com ajax") - 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``. - """ - 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")]), - ) - - def test_collection_list_alpha_without_journals(self): - """ - Teste para avaliar o retorno da ``view function`` collection_list_alpha - quando não existe periódicos cadastrados deve retorna a msg - ``Nenhum periódico encontrado`` no corpo da resposta. - """ - - utils.makeOneCollection() - response = self.client.get(url_for("main.collection_list")) - - self.assertStatus(response, 200) - self.assertTemplateUsed("collection/list_journal.html") - - self.assertIn("Nenhum periódico encontrado", response.data.decode("utf-8")) - - @unittest.skip("Revisar/Refazer, agora a lista é carregada com ajax") - 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``. - """ - - 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")) - - def test_collection_list_theme_without_journals(self): - """ - Teste para avaliar o retorno da ``view function`` collection_list_theme - quando não existe periódicos cadastrados deve retorna a msg - ``Nenhum periódico encontrado`` no corpo da resposta. - """ - - utils.makeOneCollection() - response = self.client.get(url_for("main.collection_list")) - - self.assertStatus(response, 200) - self.assertTemplateUsed("collection/list_journal.html") - - self.assertIn("Nenhum periódico encontrado", response.data.decode("utf-8")) - - @unittest.skip("Revisar/Refazer, agora a lista é carregada com ajax") - 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. - """ - - 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") - - 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. - """ - - utils.makeOneCollection() - response = self.client.get(url_for("main.collection_list")) - - self.assertStatus(response, 200) - self.assertTemplateUsed("collection/list_journal.html") - - self.assertIn("Nenhum periódico encontrado", response.data.decode("utf-8")) - - 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(): - 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_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(): - utils.makeOneCollection() - - response = self.client.get(url_for("main.collection_list_feed")) - - self.assertStatus(response, 200) - self.assertIn("Nenhum periódico encontrado", response.data.decode("utf-8")) - - 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 número, deve retornar na interface do - rss, utilizando o template ``collection/list_feed_content.html```. - """ - - with current_app.app_context(): - 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")) - - 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(): - utils.makeOneCollection() - journal = utils.makeOneJournal({"title": "Revista X"}) - issue = utils.makeOneIssue({"journal": journal}) - 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") - - def test_journal_feed_has_doi(self): - """ - Teste da ``view function`` ``journal_feed``, deve retornar um rss - que usa o template ``issue/feed_content.html`` e os respectivos artigo com DOI. - """ - - with current_app.app_context(): - utils.makeOneCollection() - journal = utils.makeOneJournal({"title": "Revista X"}) - issue = utils.makeOneIssue({"journal": journal}) - utils.makeAnyArticle( - issue=issue, - attrib={ - "journal": journal.id, - "issue": issue.id, - "doi": "10.2105/AJPH.2009.160184", - }, - ) - - 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") - self.assertIn( - "Código de idioma inválido
" - -# with self.client as c: -# response = c.get(url_for("main.set_locale", lang_code="en_US")) -# self.assertEqual(400, response.status_code) -# self.assertIn("Código de idioma inválido", response.data.decode("utf-8")) -# self.assertTemplateUsed("errors/400.html") - -# self.assertEqual(expected_message, self.get_context_variable("message")) - -# @unittest.skip("Revisar/Refazer, agora a lista é carregada com ajax") -# 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``. -# """ -# 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")]), -# ) - -# def test_collection_list_alpha_without_journals(self): -# """ -# Teste para avaliar o retorno da ``view function`` collection_list_alpha -# quando não existe periódicos cadastrados deve retorna a msg -# ``Nenhum periódico encontrado`` no corpo da resposta. -# """ - -# utils.makeOneCollection() -# response = self.client.get(url_for("main.collection_list")) - -# self.assertStatus(response, 200) -# self.assertTemplateUsed("collection/list_journal.html") - -# self.assertIn("Nenhum periódico encontrado", response.data.decode("utf-8")) - -# @unittest.skip("Revisar/Refazer, agora a lista é carregada com ajax") -# 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``. -# """ - -# 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")) - -# def test_collection_list_theme_without_journals(self): -# """ -# Teste para avaliar o retorno da ``view function`` collection_list_theme -# quando não existe periódicos cadastrados deve retorna a msg -# ``Nenhum periódico encontrado`` no corpo da resposta. -# """ - -# utils.makeOneCollection() -# response = self.client.get(url_for("main.collection_list")) - -# self.assertStatus(response, 200) -# self.assertTemplateUsed("collection/list_journal.html") - -# self.assertIn("Nenhum periódico encontrado", response.data.decode("utf-8")) - -# @unittest.skip("Revisar/Refazer, agora a lista é carregada com ajax") -# 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. -# """ - -# 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") - -# 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. -# """ - -# utils.makeOneCollection() -# response = self.client.get(url_for("main.collection_list")) - -# self.assertStatus(response, 200) -# self.assertTemplateUsed("collection/list_journal.html") - -# self.assertIn("Nenhum periódico encontrado", response.data.decode("utf-8")) - -# 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(): -# 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_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(): -# utils.makeOneCollection() - -# response = self.client.get(url_for("main.collection_list_feed")) - -# self.assertStatus(response, 200) -# self.assertIn("Nenhum periódico encontrado", response.data.decode("utf-8")) - -# 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 número, deve retornar na interface do -# rss, utilizando o template ``collection/list_feed_content.html```. -# """ - -# with current_app.app_context(): -# 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")) - -# 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(): -# utils.makeOneCollection() -# journal = utils.makeOneJournal({"title": "Revista X"}) -# issue = utils.makeOneIssue({"journal": journal}) -# 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") - -# def test_journal_feed_has_doi(self): -# """ -# Teste da ``view function`` ``journal_feed``, deve retornar um rss -# que usa o template ``issue/feed_content.html`` e os respectivos artigo com DOI. -# """ - -# with current_app.app_context(): -# utils.makeOneCollection() -# journal = utils.makeOneJournal({"title": "Revista X"}) -# issue = utils.makeOneIssue({"journal": journal}) -# utils.makeAnyArticle( -# issue=issue, -# attrib={ -# "journal": journal.id, -# "issue": issue.id, -# "doi": "10.2105/AJPH.2009.160184", -# }, -# ) - -# 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") -# self.assertIn( -# "Código de idioma inválido
" + + with self.client as c: + response = c.get(url_for("main.set_locale", lang_code="en_US")) + self.assertEqual(400, response.status_code) + self.assertIn("Código de idioma inválido", response.data.decode("utf-8")) + self.assertTemplateUsed("errors/400.html") + + self.assertEqual(expected_message, self.get_context_variable("message")) + + @unittest.skip("Revisar/Refazer, agora a lista é carregada com ajax") + 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``. + """ + 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")]), + ) + + def test_collection_list_alpha_without_journals(self): + """ + Teste para avaliar o retorno da ``view function`` collection_list_alpha + quando não existe periódicos cadastrados deve retorna a msg + ``Nenhum periódico encontrado`` no corpo da resposta. + """ + + utils.makeOneCollection() + response = self.client.get(url_for("main.collection_list")) + + self.assertStatus(response, 200) + self.assertTemplateUsed("collection/list_journal.html") + + self.assertIn("Nenhum periódico encontrado", response.data.decode("utf-8")) + + @unittest.skip("Revisar/Refazer, agora a lista é carregada com ajax") + 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``. + """ + + 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")) + + def test_collection_list_theme_without_journals(self): + """ + Teste para avaliar o retorno da ``view function`` collection_list_theme + quando não existe periódicos cadastrados deve retorna a msg + ``Nenhum periódico encontrado`` no corpo da resposta. + """ + + utils.makeOneCollection() + response = self.client.get(url_for("main.collection_list")) + + self.assertStatus(response, 200) + self.assertTemplateUsed("collection/list_journal.html") + + self.assertIn("Nenhum periódico encontrado", response.data.decode("utf-8")) + + @unittest.skip("Revisar/Refazer, agora a lista é carregada com ajax") + 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. + """ + + 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") + + 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. + """ + + utils.makeOneCollection() + response = self.client.get(url_for("main.collection_list")) + + self.assertStatus(response, 200) + self.assertTemplateUsed("collection/list_journal.html") + + self.assertIn("Nenhum periódico encontrado", response.data.decode("utf-8")) + + 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(): + 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_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(): + utils.makeOneCollection() + + response = self.client.get(url_for("main.collection_list_feed")) + + self.assertStatus(response, 200) + self.assertIn("Nenhum periódico encontrado", response.data.decode("utf-8")) + + 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 número, deve retornar na interface do + rss, utilizando o template ``collection/list_feed_content.html```. + """ + + with current_app.app_context(): + 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")) + + 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(): + utils.makeOneCollection() + journal = utils.makeOneJournal({"title": "Revista X"}) + issue = utils.makeOneIssue({"journal": journal}) + 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") + + def test_journal_feed_has_doi(self): + """ + Teste da ``view function`` ``journal_feed``, deve retornar um rss + que usa o template ``issue/feed_content.html`` e os respectivos artigo com DOI. + """ + + with current_app.app_context(): + utils.makeOneCollection() + journal = utils.makeOneJournal({"title": "Revista X"}) + issue = utils.makeOneIssue({"journal": journal}) + utils.makeAnyArticle( + issue=issue, + attrib={ + "journal": journal.id, + "issue": issue.id, + "doi": "10.2105/AJPH.2009.160184", + }, + ) + + 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") + self.assertIn( + "