<commit_before># coding: utf-8

from __future__ import unicode_literals
from django.utils.encoding import smart_text
from ...models import *
from .utils import new, CommonTestCase


class IndividuTestCase(CommonTestCase):
    model = Oeuvre

    def setUp(self):
        jb = new(Prenom, prenom='Jean-Baptiste', favori=True, classement=1.0)
        self.moliere = new(Individu, nom='Poquelin', pseudonyme='Molière',
                           designation='P')
        self.moliere.prenoms.add(jb)
        edith = new(Prenom, prenom='Édith', favori=True, classement=1.0)
        giovanna = new(Prenom, prenom='Giovanna', favori=False, classement=2.0)
        self.piaf = new(Individu, nom='Gassion', pseudonyme='<NAME>',
                        designation='S', titre='F')
        self.piaf.prenoms.add(edith, giovanna)

    def testComputedNames(self):
        self.assertEqual(smart_text(self.moliere), 'Molière')
        self.assertEqual(self.moliere.nom_complet(tags=False),
                         '<NAME>, dit Molière')
        self.assertEqual(smart_text(self.piaf),
                         'Gassion (É.), dite La Môme Piaf')
        self.assertEqual(self.piaf.nom_complet(tags=False),
                         '<NAME>, dite La Môme Piaf')

    def testHTMLRenders(self):
        moliere_url = self.moliere.get_absolute_url()
        self.assertHTMLEqual(self.moliere.html(),
                             '<a href="%(url)s">'
                             '<span class="sc">Molière</span></a>'
                             % {'url': moliere_url})
        self.assertHTMLEqual(self.moliere.nom_complet(),
                             '<a href="%(url)s">Jean-Baptiste '
                             '<span class="sc">Poquelin</span>, '
                             'dit Molière</a>'
                             % {'url': moliere_url})
        piaf_url = self.piaf.get_absolute_url()
        self.assertHTMLEqual(self.piaf.html(),
                             '<a href="%(url)s">'
                             '<span class="sc">Gassion</span> '
                             '(<span title="\xc9dith">\xc9.</span>), '
                             'dite La Môme Piaf</a>'
                             % {'url': piaf_url})
        self.assertHTMLEqual(self.piaf.nom_complet(),
                             '<a href="%(url)s"><NAME> '
                             '<span class="sc">Gassion</span>, '
                             'dite La Môme Piaf</a>'
                             % {'url': piaf_url})

    def testTemplateRenders(self):
        for individu in Individu.objects.all():
            self.assertURL(individu.get_absolute_url())<commit_msg>Met à jour les tests.<commit_after># coding: utf-8

from __future__ import unicode_literals
from django.utils.encoding import smart_text
from ...models import *
from .utils import new, CommonTestCase


class IndividuTestCase(CommonTestCase):
    model = Oeuvre

    def setUp(self):
        jb = new(Prenom, prenom='Jean-Baptiste', favori=True, classement=1.0)
        self.moliere = new(Individu, nom='Poquelin', pseudonyme='Molière',
                           designation='P')
        self.moliere.prenoms.add(jb)
        edith = new(Prenom, prenom='Édith', favori=True, classement=1.0)
        giovanna = new(Prenom, prenom='Giovanna', favori=False, classement=2.0)
        self.piaf = new(Individu, nom='Gassion', pseudonyme='<NAME>',
                        designation='S', titre='F')
        self.piaf.prenoms.add(edith, giovanna)

    def testComputedNames(self):
        self.assertEqual(smart_text(self.moliere), 'Molière')
        self.assertEqual(self.moliere.nom_complet(tags=False),
                         '<NAME> dit Molière')
        self.assertEqual(smart_text(self.piaf),
                         'Gassion (É.) dite La Môme Piaf')
        self.assertEqual(self.piaf.nom_complet(tags=False),
                         '<NAME> dite La Môme Piaf')

    def testHTMLRenders(self):
        moliere_url = self.moliere.get_absolute_url()
        self.assertHTMLEqual(self.moliere.html(),
                             '<a href="%(url)s">'
                             '<span class="sc">Molière</span></a>'
                             % {'url': moliere_url})
        self.assertHTMLEqual(self.moliere.nom_complet(),
                             '<a href="%(url)s">Jean-Baptiste '
                             '<span class="sc">Poquelin</span> '
                             'dit Molière</a>'
                             % {'url': moliere_url})
        piaf_url = self.piaf.get_absolute_url()
        self.assertHTMLEqual(self.piaf.html(),
                             '<a href="%(url)s">'
                             '<span class="sc">Gassion</span> '
                             '(<span title="\xc9dith">\xc9.</span>) '
                             'dite La Môme Piaf</a>'
                             % {'url': piaf_url})
        self.assertHTMLEqual(self.piaf.nom_complet(),
                             '<a href="%(url)s"><NAME> '
                             '<span class="sc">Gassion</span> '
                             'dite La Môme Piaf</a>'
                             % {'url': piaf_url})

    def testTemplateRenders(self):
        for individu in Individu.objects.all():
            self.assertURL(individu.get_absolute_url())
{'fraction_non_alphanumeric': 0.13540489642184558, 'fraction_numerical': 0.003389830508474576, 'mean_word_length': 1.6959390862944161, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2210878', 'n_tokens_mistral': 1678, 'n_tokens_neox': 1641, 'n_words': 259}