示例#1
0
    def test_has_subtotals(self):
        r = SimpleDemoReport.as_report()

        self.assertFalse(r.has_subtotals())

        r.column_totals = ['integer1']
        self.assertTrue(r.has_subtotals())
示例#2
0
 def test_render_to_response(self):
     report = SimpleDemoReport.as_report()
     renderer = report.get_renderer_for_format('html')
     self.assertIsInstance(renderer, BaseHtmlRender)
     request = get_fake_request()
     r = renderer.render_to_response(request)
     self.assertIsInstance(r, HttpResponse)
示例#3
0
 def test_render_to_response(self):
     report = SimpleDemoReport.as_report()
     renderer = report.get_renderer_for_format('html')
     self.assertIsInstance(renderer, BaseHtmlRender)
     request = get_fake_request()
     r = renderer.render_to_response(request)
     self.assertIsInstance(r, HttpResponse)
示例#4
0
    def test_has_subtotals(self):
        r = SimpleDemoReport.as_report()

        self.assertFalse(r.has_subtotals())

        r.column_totals = ['integer1']
        self.assertTrue(r.has_subtotals())
示例#5
0
 def test_render_to_response(self):
     G(SimpleDemoModel, n=2, char='abc', integer1=1, integer2=2, boolean=True)
     G(SimpleDemoModel, n=2, char=u'êbc', integer1=1, integer2=2, boolean=True)
     report = SimpleDemoReport.as_report()
     renderer = report.get_renderer_for_format('xls')
     self.assertIsInstance(renderer, BaseXlsRender)
     request = get_fake_request()
     r = renderer.render_to_response(request)
     self.assertIsInstance(r, HttpResponse)
示例#6
0
 def test_report_groupby(self):
     r = SimpleDemoReport.as_report()
     form = reportform_factory(r, (r.config_form_class, ),
                               groupby=[
                                   ('date', 'Date'),
                               ])()
     self.assertIn('_report_group_by', form.base_fields)
     self.assertIsInstance(form.base_fields['_report_group_by'],
                           forms.ChoiceField)
示例#7
0
    def test_get_groups(self):
        r = SimpleDemoReport.as_report()

        with self.assertRaises(ImproperlyConfigured):
            r.get_groups()

        G(SimpleDateModel, char='abc', date=datetime.date.today(), date_range=datetime.date.today())
        r = SimpleDateReport.as_report(datasource=SimpleDateModelSource.as_datasource())
        g = r.get_groups()
        self.assertEqual(len(g), 1)
示例#8
0
    def test_get_filters(self):
        r = SimpleDemoReport.as_report()
        form = reportform_factory(r, (r.config_form_class, ),
                                  filtering=['integer1'])()
        form.cleaned_data = {'integer1': 1, 'char': ['a', 'b', 'c']}
        f = form.get_filters()
        self.assertSequenceEqual(([], {'integer1': 1}), f)

        form.cleaned_data = {'integer1': [1, 2, 3]}
        f = form.get_filters()
        self.assertSequenceEqual(([], {'integer1__in': [1, 2, 3]}), f)
示例#9
0
    def test_get_filters_summary(self):
        r = SimpleDemoReport.as_report()
        form = reportform_factory(r, (r.config_form_class, ))()
        form.cleaned_data = {
            'integer1': 1,
        }
        self.assertEqual(form.get_filters_summary(), {u'Integer #1': 1})

        form.cleaned_data = {'integer1': [1, 2, 3]}
        form.get_filters()
        self.assertEqual(form.get_filters_summary(),
                         {u'Integer #1': [1, 2, 3]})
示例#10
0
    def test_get_filters_summary(self):
        r = SimpleDemoReport.as_report()
        form = reportform_factory(r, (r.config_form_class,))()
        form.cleaned_data = {
            'integer1': 1,
        }
        self.assertEqual(form.get_filters_summary(), {u'Integer #1': 1})

        form.cleaned_data = {
            'integer1': [1, 2, 3]
        }
        form.get_filters()
        self.assertEqual(form.get_filters_summary(), {u'Integer #1': [1, 2, 3]})
示例#11
0
    def test_get_groups(self):
        r = SimpleDemoReport.as_report()

        with self.assertRaises(ImproperlyConfigured):
            r.get_groups()

        G(SimpleDateModel,
          char='abc',
          date=datetime.date.today(),
          date_range=datetime.date.today())
        r = SimpleDateReport.as_report(
            datasource=SimpleDateModelSource.as_datasource())
        g = r.get_groups()
        self.assertEqual(len(g), 1)
示例#12
0
    def test_get_filters(self):
        r = SimpleDemoReport.as_report()
        form = reportform_factory(r, (r.config_form_class,), filtering=['integer1'])()
        form.cleaned_data = {
            'integer1': 1,
            'char': ['a', 'b', 'c']
        }
        f = form.get_filters()
        self.assertSequenceEqual(([], {'integer1': 1}), f)

        form.cleaned_data = {
            'integer1': [1, 2, 3]
        }
        f = form.get_filters()
        self.assertSequenceEqual(([], {'integer1__in': [1, 2, 3]}), f)
示例#13
0
    def test_clean__report_group_by(self):
        r = SimpleDemoReport.as_report()
        form = reportform_factory(r, (r.config_form_class, ),
                                  groupby=[
                                      ('date', 'Date'),
                                  ])()
        form.cleaned_data = {'date': '2001-01-01', '_report_group_by': 'date'}
        self.assertIsNone(form.clean__report_group_by())

        form.cleaned_data = {
            'date': '2001-01-01',
            '_report_group_by': 'date,internal'
        }
        group, internal_order = form.clean__report_group_by()
        self.assertEqual(group, 'date')
        self.assertEqual(internal_order, 'internal')
示例#14
0
    def test_clean__report_group_by(self):
        r = SimpleDemoReport.as_report()
        form = reportform_factory(r, (r.config_form_class,), groupby=[('date', 'Date'), ])()
        form.cleaned_data = {
            'date': '2001-01-01',
            '_report_group_by': 'date'
        }
        self.assertIsNone(form.clean__report_group_by())

        form.cleaned_data = {
            'date': '2001-01-01',
            '_report_group_by': 'date,internal'
        }
        group, internal_order = form.clean__report_group_by()
        self.assertEqual(group, 'date')
        self.assertEqual(internal_order, 'internal')
示例#15
0
 def test_render_to_response(self):
     G(SimpleDemoModel,
       n=2,
       char='abc',
       integer1=1,
       integer2=2,
       boolean=True)
     G(SimpleDemoModel,
       n=2,
       char=u'êbc',
       integer1=1,
       integer2=2,
       boolean=True)
     report = SimpleDemoReport.as_report()
     renderer = report.get_renderer_for_format('xls')
     self.assertIsInstance(renderer, BaseXlsRender)
     request = get_fake_request()
     r = renderer.render_to_response(request)
     self.assertIsInstance(r, HttpResponse)
示例#16
0
 def test_format_labels(self):
     r = SimpleDemoReport.as_report()
     self.assertSequenceEqual(sorted(r.get_format_labels()), ['html', 'xls'])
示例#17
0
 def test_get_renderer_class_format(self):
     r = SimpleDemoReport.as_report()
     self.assertEqual(r.get_renderer_class_for_format('html'), BaseHtmlRender)
示例#18
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))])
示例#19
0
 def test_get_format_labels(self):
     r = SimpleDemoReport.as_report()
     self.assertEqual(r.formats_dict, {'html': BaseHtmlRender, 'xls': BaseXlsRender})
示例#20
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))])
示例#21
0
 def test_report_groupby(self):
     r = SimpleDemoReport.as_report()
     form = reportform_factory(r, (r.config_form_class,), groupby=[('date', 'Date'), ])()
     self.assertIn('_report_group_by', form.base_fields)
     self.assertIsInstance(form.base_fields['_report_group_by'], forms.ChoiceField)
示例#22
0
 def test_init(self):
     r = SimpleDemoReport.as_report()
     c = reportform_factory(r)
     self.assertIn('_format', c.base_fields)
示例#23
0
 def test_init(self):
     r = SimpleDemoReport.as_report()
     c = reportform_factory(r)
     self.assertIn('_format', c.base_fields)
示例#24
0
 def test_get_format_labels(self):
     r = SimpleDemoReport.as_report()
     self.assertEqual(r.formats_dict, {
         'html': BaseHtmlRender,
         'xls': BaseXlsRender
     })
示例#25
0
 def test_get_config_form_class(self):
     r = SimpleDemoReport.as_report()
     f = reportform_factory(r, bases=(r.config_form_class, ))
     self.assertIn('integer1', f.base_fields)
     self.assertIn('_format', f.base_fields)
示例#26
0
 def test_format_labels(self):
     r = SimpleDemoReport.as_report()
     self.assertEqual(r.get_format_labels(), ['html', 'xls'])
示例#27
0
 def test_get_renderer_class_format(self):
     r = SimpleDemoReport.as_report()
     self.assertEqual(r.get_renderer_class_for_format('html'),
                      BaseHtmlRender)
示例#28
0
 def test_get_renderer_for_format(self):
     r = SimpleDemoReport.as_report()
     renderer = r.get_renderer_for_format('html')
     self.assertIsInstance(renderer, BaseHtmlRender)
示例#29
0
 def test_get_renderer_for_format(self):
     r = SimpleDemoReport.as_report()
     renderer = r.get_renderer_for_format('html')
     self.assertIsInstance(renderer, BaseHtmlRender)
示例#30
0
 def test_get_lookup_fields(self):
     r = SimpleDemoReport.as_report()
     form = reportform_factory(r, (r.config_form_class, ),
                               filtering=['integer1'])()
     f = form.get_lookup_fields()
     self.assertEqual(['integer1'], f)
示例#31
0
 def test_get_lookup_fields(self):
     r = SimpleDemoReport.as_report()
     form = reportform_factory(r, (r.config_form_class,), filtering=['integer1'])()
     f = form.get_lookup_fields()
     self.assertEqual(['integer1'], f)
示例#32
0
 def test_repr(self):
     r = SimpleDemoReport.as_report()
     self.assertEqual(repr(r), "<SimpleDemoReport: on `SimpleDemoModel`>")
示例#33
0
 def test_datasource_custom_list_display(self):
     G(SimpleDemoModel, n=2, char='abc', integer1=10, integer2=20)
     r = SimpleDemoReport.as_report()
     self.assertEqual(r.datasource[1].values(), [u'abc', 10])
     self.assertEqual(r[1], (u'abc',))
     self.assertSequenceEqual(r[:1], [(u'abc',)])
示例#34
0
 def test_format_labels(self):
     r = SimpleDemoReport.as_report()
     self.assertEqual(r.get_format_labels(), ['html', 'xls'])
示例#35
0
 def test_repr(self):
     r = SimpleDemoReport.as_report()
     self.assertEqual(repr(r), "<SimpleDemoReport: on `SimpleDemoModel`>")
示例#36
0
 def test_get_config_form_class(self):
     r = SimpleDemoReport.as_report()
     f = reportform_factory(r, bases=(r.config_form_class,))
     self.assertIn('integer1', f.base_fields)
     self.assertIn('_format', f.base_fields)
示例#37
0
 def test_format_labels(self):
     r = SimpleDemoReport.as_report()
     self.assertSequenceEqual(sorted(r.get_format_labels()),
                              ['html', 'xls'])
示例#38
0
 def test_datasource_custom_list_display(self):
     G(SimpleDemoModel, n=2, char='abc', integer1=10, integer2=20)
     r = SimpleDemoReport.as_report()
     self.assertEqual(r.datasource[1].values(), [u'abc', 10])
     self.assertEqual(r[1], (u'abc', ))
     self.assertSequenceEqual(r[:1], [(u'abc', )])