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)

@@ -414,16 +414,60 @@
 10-10',%0A
+            'titulo_de_ley': 'Ley No 2261',%0A
         
@@ -1190,8 +1190,192 @@
 result)%0A
+%0A    def test_percentage_arent_law(self):%0A        result = views.get_projects_that_arent_law(1)%0A        expected = (0, 0.0, %7B'Ley No 2261'%7D)%0A        self.assertEqual(expected, result)%0A

test stats: percentage projects are not law