<commit_before>import datetime

from django.test import TestCase, Client

from pdl.models import Proyecto
from stats.models import Dispensed
from stats.models import ComisionCount
from stats import views


class TestStatsViews(TestCase):
    def setUp(self):
        Proyecto.objects.create(**{
            'numero_proyecto': '02764',
            'time_created': datetime.datetime.now(),
            'fecha_presentacion': '2010-10-10',
        })
        Dispensed.objects.create(**{
            'total_approved': 1444,
            'total_dispensed': 864,
            'dispensed_by_plenary': 23,
            'dispensed_by_spokesmen': 12,
            'dispensed_others': 11,
        })
        ComisionCount.objects.create(**{
            'count': 7,
            'comision': 'Justicia',
        })

    def test_index(self):
        c = Client()
        response = c.get('/stats/')
        self.assertEqual(200, response.status_code)

    def test_dame_sin_tramitar(self):
        numero_de_proyectos = Proyecto.objects.all().count()
        expected = (100.0, 1)
        result = views.dame_sin_tramitar(numero_de_proyectos)
        self.assertEqual(expected, result)<commit_msg>test stats: percentage projects are not law<commit_after>import datetime

from django.test import TestCase, Client

from pdl.models import Proyecto
from stats.models import Dispensed
from stats.models import ComisionCount
from stats import views


class TestStatsViews(TestCase):
    def setUp(self):
        Proyecto.objects.create(**{
            'numero_proyecto': '02764',
            'time_created': datetime.datetime.now(),
            'fecha_presentacion': '2010-10-10',
            'titulo_de_ley': 'Ley No 2261',
        })
        Dispensed.objects.create(**{
            'total_approved': 1444,
            'total_dispensed': 864,
            'dispensed_by_plenary': 23,
            'dispensed_by_spokesmen': 12,
            'dispensed_others': 11,
        })
        ComisionCount.objects.create(**{
            'count': 7,
            'comision': 'Justicia',
        })

    def test_index(self):
        c = Client()
        response = c.get('/stats/')
        self.assertEqual(200, response.status_code)

    def test_dame_sin_tramitar(self):
        numero_de_proyectos = Proyecto.objects.all().count()
        expected = (100.0, 1)
        result = views.dame_sin_tramitar(numero_de_proyectos)
        self.assertEqual(expected, result)

    def test_percentage_arent_law(self):
        result = views.get_projects_that_arent_law(1)
        expected = (0, 0.0, {'Ley No 2261'})
        self.assertEqual(expected, result)
{'fraction_non_alphanumeric': 0.11238532110091744, 'fraction_numerical': 0.03134556574923547, 'mean_word_length': 2.4662251655629137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6948989', 'n_tokens_mistral': 866, 'n_tokens_neox': 804, 'n_words': 159}