<commit_before># coding: utf-8

from flask import url_for, current_app
from flask_babelex import lazy_gettext as __

from .base import BaseTestCase
from . import utils


class MenuTestCase(BaseTestCase):

    # Collection Menu

    def test_alpha_link_is_selected_for_list_alpha(self):
        """
        Verficamos que o link do menú "Alfabética" tem o css:
        "selected" quando acessamos a view "collection_list_alpha"
        """
        response = self.client.get(url_for('main.collection_list'))

        self.assertStatus(response, 200)
        self.assertTemplateUsed('collection/list_journal.html')
        expected_anchor = '<a href="/journals/#alpha" class="tab_link">\n              Lista alfab\xe9tica de peri\xf3dicos\n            </a>'
        self.assertIn(expected_anchor, response.data.decode('utf-8'))

    def test_theme_link_is_selected_for_list_theme(self):
        """
        Verficamos que o link do menú "Temática" tem o css:
        "selected" quando acessamos a view "collection_list_theme"
        """
        response = self.client.get(url_for('main.collection_list'))

        self.assertStatus(response, 200)
        self.assertTemplateUsed('collection/list_journal.html')
        expected_anchor = '<a href="/journals/#theme" class="tab_link">\n              Lista temática de periódicos\n            </a>'
        self.assertIn(expected_anchor, response.data.decode('utf-8'))

    # def test_institution_link_is_selected_for_list_institution(self):
    #     """
    #     Verficamos que o link do menú "Por instituição" tem o css:
    #     "selected" quando acessamos a view "collection_list_institution"
    #     """
    #     response = self.client.get(url_for('main.collection_list'))

    #     self.assertStatus(response, 200)
    #     self.assertTemplateUsed('collection/list_journal.html')
    #     expected_anchor = '<a href="/journals/#publisher" class="tab_link">\n              Lista de periódicos por editoras\n            </a>'
    #     self.assertIn(expected_anchor, response.data.decode('utf-8'))

    # Hamburger Menu
    def test_links_in_hamburger_menu(self):
        """
        no menú de hamurger, verificamos os links que apontam a views do opac
        """
        with current_app.app_context():
            collection = utils.makeOneCollection({'name': 'dummy collection'})

            with self.client as c:

                response = c.get(url_for('main.index'))
                response_data = response.data.decode('utf-8')
                self.assertStatus(response, 200)
                expected_anchor1 = """<a href="%s">\n        <strong>%s</strong>""" % (url_for('.index'), collection.name or __('NOME DA COLEÇÃO!!'))
                self.assertIn(expected_anchor1, response_data)
                expected_anchor2 = """<li>\n            <a href="%s" class="tab_link">\n              %s\n            </a>\n          </li>""" % (url_for('.collection_list') + '#alpha', __('Lista alfabética de periódicos'))
                self.assertIn(expected_anchor2, response_data)
                expected_anchor3 = """<li>\n            <a href="%s" class="tab_link">\n              %s\n            </a>\n          </li>""" % (url_for('.collection_list') + '#theme', __('Lista temática de periódicos'))
                self.assertIn(expected_anchor3, response_data)
                # expected_anchor4 = """<li>\n            <a href="%s" class="tab_link">\n              %s\n            </a>\n          </li>""" % (url_for('.collection_list') + '#publisher', __('Lista de periódicos por editoras'))
                # self.assertIn(expected_anchor4, response_data)
                expected_anchor5 = """<li>\n            <a href="%s">\n              %s\n            </a>\n          </li>""" % (current_app.config['URL_SEARCH'] + "?q=*&lang=pt&filter[in][]=" + current_app.config['OPAC_COLLECTION'], 'Busca')
                self.assertIn(expected_anchor5, response_data)
                expected_anchor6 = """<li>\n            <a target="_blank" href="%s/?collection=%s">\n              %s\n            </a>\n          </li>\n          <li>""" % (current_app.config['METRICS_URL'], current_app.config['OPAC_COLLECTION'], __('M\xe9tricas'))
                self.assertIn(expected_anchor6, response_data)
                expected_anchor7 = """<a href="%s" class="onlineSubmission"><span class="glyphBtn infoMenu"></span>%s %s</a>""" % (url_for('.about_collection'), __('Sobre o SciELO'), collection.name)
                self.assertIn(expected_anchor7, response_data)
                expected_anchor8 = """<li>\n            <a href="/collection/about/">\n              %s\n            </a>\n          </li>""" % __('Contatos')
                self.assertIn(expected_anchor8, response_data)
                expected_anchor9 = """<a href="#">\n        <strong>SciELO.org - %s</strong>\n      </a>""" % __('Rede SciELO')
                self.assertIn(expected_anchor9, response_data)
                # rede/scielo org
                expected_anchor10 = """<li>\n          <a href="http://www.scielo.org/php/index.php">\n            %s\n          </a>\n        </li>""" % __('Coleções nacionais e temáticas')
                self.assertIn(expected_anchor10, response_data)
                expected_anchor11 = """<li>\n          <a href="http://www.scielo.org/applications/scielo-org/php/secondLevel.php?xml=secondLevelForAlphabeticList&xsl=secondLevelForAlphabeticList">\n            %s\n          </a>\n        </li>""" % __('Lista alfabética de periódicos')
                self.assertIn(expected_anchor11, response_data)
                expected_anchor12 = """<li>\n          <a href="http://www.scielo.org/applications/scielo-org/php/secondLevel.php?xml=secondLevelForSubjectByLetter&xsl=secondLevelForSubjectByLetter">\n            %s\n          </a>\n        </li>""" % __('Lista de periódicos por assunto')
                self.assertIn(expected_anchor12, response_data)
                expected_anchor13 = """<li>\n          <a href="%s">\n            %s\n          </a>\n        </li>""" % (current_app.config['URL_SEARCH'], 'Busca')
                self.assertIn(expected_anchor13, response_data)
                expected_anchor14 = """<li>\n            <a target="_blank" href="%s/?collection=%s">\n              %s\n            </a>\n          </li>""" % (current_app.config['METRICS_URL'], current_app.config['OPAC_COLLECTION'], 'Métricas')
                self.assertIn(expected_anchor14, response_data)
                expected_anchor15 = """<li>\n          <a href="http://www.scielo.org/php/level.php?lang=pt&component=56&item=9">\n            %s\n          </a>\n        </li>""" % __('Acesso OAI e RSS')
                self.assertIn(expected_anchor15, response_data)
                expected_anchor16 = """<li>\n          <a href="http://www.scielo.org/php/level.php?lang=pt&component=56&item=8">\n            %s\n          </a>\n        </li>""" % __('Sobre a Rede SciELO')
                self.assertIn(expected_anchor16, response_data)
                expected_anchor17 = """<li>\n          <a href="#">\n            %s\n          </a>\n        </li>""" % __('Contatos')
                self.assertIn(expected_anchor17, response_data)
                # expected_anchor18 = u"""<li>\n      <a href="#"><strong>%s</strong></a>\n    </li>""" % __(u'Portal do Autor')
                # self.assertIn(expected_anchor18, response_data)

    def test_blog_link_in_hamburger_menu(self):<commit_msg>fix: testes<commit_after># coding: utf-8

from flask import url_for, current_app
from flask_babelex import lazy_gettext as __

from .base import BaseTestCase
from . import utils


class MenuTestCase(BaseTestCase):

    # Collection Menu

    def test_alpha_link_is_selected_for_list_alpha(self):
        """
        Verficamos que o link do menú "Alfabética" tem o css:
        "selected" quando acessamos a view "collection_list_alpha"
        """
        response = self.client.get(url_for('main.collection_list'))

        self.assertStatus(response, 200)
        self.assertTemplateUsed('collection/list_journal.html')
        expected_anchor = '<a href="/journals/#alpha" class="tab_link">\n              Lista alfab\xe9tica de peri\xf3dicos\n            </a>'
        self.assertIn(expected_anchor, response.data.decode('utf-8'))

    def test_theme_link_is_selected_for_list_theme(self):
        """
        Verficamos que o link do menú "Temática" tem o css:
        "selected" quando acessamos a view "collection_list_theme"
        """
        response = self.client.get(url_for('main.collection_list'))

        self.assertStatus(response, 200)
        self.assertTemplateUsed('collection/list_journal.html')
        expected_anchor = '<a href="/journals/#theme" class="tab_link">\n              Lista temática de periódicos\n            </a>'
        self.assertIn(expected_anchor, response.data.decode('utf-8'))

    # def test_institution_link_is_selected_for_list_institution(self):
    #     """
    #     Verficamos que o link do menú "Por instituição" tem o css:
    #     "selected" quando acessamos a view "collection_list_institution"
    #     """
    #     response = self.client.get(url_for('main.collection_list'))

    #     self.assertStatus(response, 200)
    #     self.assertTemplateUsed('collection/list_journal.html')
    #     expected_anchor = '<a href="/journals/#publisher" class="tab_link">\n              Lista de periódicos por editoras\n            </a>'
    #     self.assertIn(expected_anchor, response.data.decode('utf-8'))

    # Hamburger Menu
    def test_links_in_hamburger_menu(self):
        """
        no menú de hamurger, verificamos os links que apontam a views do opac
        """
        with current_app.app_context():
            collection = utils.makeOneCollection({'name': 'dummy collection'})

            with self.client as c:

                response = c.get(url_for('main.index'))
                response_data = response.data.decode('utf-8')
                self.assertStatus(response, 200)
                expected_anchor1 = """<a href="%s">\n        <strong>%s</strong>""" % (url_for('.index'), collection.name or __('NOME DA COLEÇÃO!!'))
                self.assertIn(expected_anchor1, response_data)
                expected_anchor2 = """<li>\n            <a href="%s" class="tab_link">\n              %s\n            </a>\n          </li>""" % (url_for('.collection_list') + '#alpha', __('Lista alfabética de periódicos'))
                self.assertIn(expected_anchor2, response_data)
                expected_anchor3 = """<li>\n            <a href="%s" class="tab_link">\n              %s\n            </a>\n          </li>""" % (url_for('.collection_list') + '#theme', __('Lista temática de periódicos'))
                self.assertIn(expected_anchor3, response_data)
                # expected_anchor4 = """<li>\n            <a href="%s" class="tab_link">\n              %s\n            </a>\n          </li>""" % (url_for('.collection_list') + '#publisher', __('Lista de periódicos por editoras'))
                # self.assertIn(expected_anchor4, response_data)
                expected_anchor5 = """<li>\n            <a href="%s">\n              %s\n            </a>\n          </li>""" % (current_app.config['URL_SEARCH'] + "?q=*&lang=pt&filter[in][]=" + current_app.config['OPAC_COLLECTION'], 'Busca')
                self.assertIn(expected_anchor5, response_data)
                expected_anchor6 = """<li>\n            <a target="_blank" href="%s/?collection=%s">\n              %s\n            </a>\n          </li>\n          <li>""" % (current_app.config['METRICS_URL'], current_app.config['OPAC_COLLECTION'], __('M\xe9tricas'))
                self.assertIn(expected_anchor6, response_data)
                expected_anchor7 = """<a href="%s" class="onlineSubmission">\n      <span class="glyphBtn infoMenu"></span>\n      %s %s\n    </a>""" % (url_for('.about_collection'), __('Sobre o SciELO'), collection.name)
                self.assertIn(expected_anchor7, response_data)
                expected_anchor8 = """<li>\n            <a href="/collection/about/">\n              %s\n            </a>\n          </li>""" % __('Contatos')
                self.assertIn(expected_anchor8, response_data)
                expected_anchor9 = """<a href="#">\n        <strong>SciELO.org - %s</strong>\n      </a>""" % __('Rede SciELO')
                self.assertIn(expected_anchor9, response_data)
                # rede/scielo org
                expected_anchor10 = """<li>\n          <a href="http://www.scielo.org/php/index.php">\n            %s\n          </a>\n        </li>""" % __('Coleções nacionais e temáticas')
                self.assertIn(expected_anchor10, response_data)
                expected_anchor11 = """<li>\n          <a href="http://www.scielo.org/applications/scielo-org/php/secondLevel.php?xml=secondLevelForAlphabeticList&xsl=secondLevelForAlphabeticList">\n            %s\n          </a>\n        </li>""" % __('Lista alfabética de periódicos')
                self.assertIn(expected_anchor11, response_data)
                expected_anchor12 = """<li>\n          <a href="http://www.scielo.org/applications/scielo-org/php/secondLevel.php?xml=secondLevelForSubjectByLetter&xsl=secondLevelForSubjectByLetter">\n            %s\n          </a>\n        </li>""" % __('Lista de periódicos por assunto')
                self.assertIn(expected_anchor12, response_data)
                expected_anchor13 = """<li>\n          <a href="%s">\n            %s\n          </a>\n        </li>""" % (current_app.config['URL_SEARCH'], 'Busca')
                self.assertIn(expected_anchor13, response_data)
                expected_anchor14 = """<li>\n            <a target="_blank" href="%s/?collection=%s">\n              %s\n            </a>\n          </li>""" % (current_app.config['METRICS_URL'], current_app.config['OPAC_COLLECTION'], 'Métricas')
                self.assertIn(expected_anchor14, response_data)
                expected_anchor15 = """<li>\n          <a href="http://www.scielo.org/php/level.php?lang=pt&component=56&item=9">\n            %s\n          </a>\n        </li>""" % __('Acesso OAI e RSS')
                self.assertIn(expected_anchor15, response_data)
                expected_anchor16 = """<li>\n          <a href="http://www.scielo.org/php/level.php?lang=pt&component=56&item=8">\n            %s\n          </a>\n        </li>""" % __('Sobre a Rede SciELO')
                self.assertIn(expected_anchor16, response_data)
                expected_anchor17 = """<li>\n          <a href="#">\n            %s\n          </a>\n        </li>""" % __('Contatos')
                self.assertIn(expected_anchor17, response_data)
                # expected_anchor18 = u"""<li>\n      <a href="#"><strong>%s</strong></a>\n    </li>""" % __(u'Portal do Autor')
                # self.assertIn(expected_anchor18, response_data)

    def test_blog_link_in_hamburger_menu(self):
{'fraction_non_alphanumeric': 0.14980622744888414, 'fraction_numerical': 0.010690899371909661, 'mean_word_length': 2.185145775696957, 'pattern_counts': {'":': 0, '<': 163, '<?xml version=': 0, '>': 163, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4871525', 'n_tokens_mistral': 4756, 'n_tokens_neox': 4560, 'n_words': 797}