def test_nonzero(self): f = FilterSpec(value='abc') self.assertEqual(bool(f), True) f = FilterSpec() self.assertEqual(bool(f), False) f = FilterSpec(value='') self.assertEqual(bool(f), False)
def test_get_filter_description(self): f = FilterSpec(value='abc') self.assertEqual(f.get_filter_description('char'), "abc")
def test_get_filter(self): f = FilterSpec(value='abc') self.assertEqual(f.get_filter(), 'abc')
def test_init(self): f = FilterSpec() self.assertEqual(f._value, {}) f = FilterSpec(value='abc') self.assertEqual(f._value, 'abc')
def test_get_filters_summary_filterspec(self): r = FilterSpecDemoReport.as_report() form = reportform_factory(r, (r.config_form_class, ))() form.cleaned_data = {'date_range': FilterSpec('2001')} self.assertEqual(form.get_filters_summary(), {u'Date Range': '2001'})
def test_get_filters_filterspec_dict(self): r = FilterSpecDemoReport.as_report() form = reportform_factory(r, (r.config_form_class, ))() form.cleaned_data = {'date_range': FilterSpec({1: '2001'})} f = form.get_filters() self.assertSequenceEqual(([], {1: '2001'}), f)