Exemplo n.º 1
0
 def test_keys(self):
     G(SimpleDateModel,
       char='abc',
       date=datetime.date.today(),
       date_range=datetime.date.today())
     r = SimpleDateReport.as_report()
     g = BaseGrouper(r, 'char', 'Groups')
     self.assertEqual(g.keys(), [u'abc'])
Exemplo n.º 2
0
 def test_items_callable(self):
     G(SimpleDateModel,
       char='abc',
       date=datetime.date.today(),
       date_range=datetime.date.today())
     r = SimpleDateReport.as_report()
     g = BaseGrouper(r, fake_callable, 'Groups')
     self.assertEqual(list(g.items()), [(u'cba', list(r))])
Exemplo n.º 3
0
    def test_items_basestring(self):
        G(SimpleDateModel, char='abc', date=datetime.date.today(), date_range=datetime.date.today())
        r = SimpleDateReport.as_report()
        g = BaseGrouper(r, 'char', 'Character')
        self.assertEqual(list(g.items()), [(u'abc', list(r))])
        self.assertTrue(g._processed)

        # call again to ensure _processed param handled properly and no error
        g._process()
        self.assertTrue(g._processed)
Exemplo n.º 4
0
    def test_items_sorted(self):
        G(SimpleDateModel, char='cba', date=datetime.date.today(), date_range=datetime.date.today())
        G(SimpleDateModel, char='bac', date=datetime.date.today(), date_range=datetime.date.today())
        G(SimpleDateModel, char='abc', date=datetime.date.today(), date_range=datetime.date.today())
        r = SimpleDateReport.as_report()
        g = BaseGrouper(r, 'char', 'Groups')
        expected = [(u'abc', [r[2]]),
                    (u'bac', [r[1]]),
                    (u'cba', [r[0]])]

        self.assertEqual(list(g.items()), expected)
Exemplo n.º 5
0
    def test_items_basestring(self):
        G(SimpleDateModel,
          char='abc',
          date=datetime.date.today(),
          date_range=datetime.date.today())
        r = SimpleDateReport.as_report()
        g = BaseGrouper(r, 'char', 'Character')
        self.assertEqual(list(g.items()), [(u'abc', list(r))])
        self.assertTrue(g._processed)

        # call again to ensure _processed param handled properly and no error
        g._process()
        self.assertTrue(g._processed)
Exemplo n.º 6
0
    def test_items_sorted(self):
        G(SimpleDateModel,
          char='cba',
          date=datetime.date.today(),
          date_range=datetime.date.today())
        G(SimpleDateModel,
          char='bac',
          date=datetime.date.today(),
          date_range=datetime.date.today())
        G(SimpleDateModel,
          char='abc',
          date=datetime.date.today(),
          date_range=datetime.date.today())
        r = SimpleDateReport.as_report()
        g = BaseGrouper(r, 'char', 'Groups')
        expected = [(u'abc', [r[2]]), (u'bac', [r[1]]), (u'cba', [r[0]])]

        self.assertEqual(list(g.items()), expected)
Exemplo n.º 7
0
 def test_keys(self):
     G(SimpleDateModel, char='abc', date=datetime.date.today(), date_range=datetime.date.today())
     r = SimpleDateReport.as_report()
     g = BaseGrouper(r, 'char', 'Groups')
     self.assertEqual(g.keys(), [u'abc'])
Exemplo n.º 8
0
 def test_items_other(self):
     G(SimpleDemoModel, char='abc')
     r = SimpleDemoReport.as_report()
     r.list_display = ['char', 'integer1']
     g = BaseGrouper(r, 'wrong', 'wrong')
     self.assertEqual(list(g.items()), [(None, list(r))])
Exemplo n.º 9
0
 def test_items_callable(self):
     G(SimpleDateModel, char='abc', date=datetime.date.today(), date_range=datetime.date.today())
     r = SimpleDateReport.as_report()
     g = BaseGrouper(r, fake_callable, 'Groups')
     self.assertEqual(list(g.items()), [(u'cba', list(r))])
Exemplo n.º 10
0
 def test_items_other(self):
     G(SimpleDemoModel, char='abc')
     r = SimpleDemoReport.as_report()
     r.list_display = ['char', 'integer1']
     g = BaseGrouper(r, 'wrong', 'wrong')
     self.assertEqual(list(g.items()), [(None, list(r))])
Exemplo n.º 11
0
 def test_init(self):
     g = BaseGrouper(SimpleDemoReport, 'char', 'Character')
     self.assertEqual(g.report, SimpleDemoReport)
     self.assertEqual(g.group_by, 'char')
     self.assertEqual(g.internal_order, 'Character')
     self.assertFalse(g._processed)