Esempio n. 1
0
    def test_statistic(self):
        stat = Statistic('Test', keys=['foo', 'bar'], description='Statistic Example')
        stat.add([1, 2])

        self.assertEqual(stat.slug(), 'Test')

        table = stat.render_rows()

        self.assertEqual(table, '<tr><th>foo</th><th>bar</th></tr>\n<tr><td>1</td><td>2</td></tr>\n')
Esempio n. 2
0
    def test_statistic_from_queryset(self):
        User.objects.create(email='*****@*****.**', username='******')
        User.objects.create(email='*****@*****.**', username='******')

        stat = Statistic.from_queryset('Number of users', User.objects.all())

        stat.render_rows()
Esempio n. 3
0
 def test_statistic_from_iterable(self):
     datasource = zip(range(10), range(10, 20))
     stat = Statistic.from_iterable(
         'Test iterable', datasource,
         keys=['foo', 'bar']
     )
     stat.render_rows()