def setUp(self): Status.delete_cascaded() Person.testing_create() Person.testing_create() Person.testing_create() Person.testing_create() Person.testing_create()
def test_subtotal_avg(self): class CTG(Grid): Column('Sum Total', Person.numericcol.label('something'), has_subtotal='avg') Person.testing_create(numericcol=5) Person.testing_create(numericcol=10) g = CTG() totals = g.grand_totals assert totals.something == Decimal('7.5')
def test_subtotal_sum_by_default(self): class CTG(Grid): Column('Sum Total', Person.numericcol.label('something'), has_subtotal=True) Person.testing_create(numericcol=5) Person.testing_create(numericcol=10) g = CTG() totals = g.grand_totals assert totals.something == 15
def test_subtotal_expr_string(self): class CTG(Grid): ratio_expr = Person.numericcol / Person.sortorder Column('Numeric', Person.numericcol.label('numeric_col'), has_subtotal=True) Column('Ints', Person.floatcol.label('float_col'), has_subtotal=True) Column('Ratio', Person.numericcol.label('something'), has_subtotal='sum(numeric_col) / sum(float_col)') Person.testing_create(numericcol=5, floatcol=1) Person.testing_create(numericcol=10, floatcol=3) g = CTG() totals = g.grand_totals assert totals.something == Decimal('3.75'), totals
def test_subtotal_sum_by_default(self, m_debug): class CTG(Grid): Column('Sum Total', Person.numericcol.label('something'), has_subtotal=True) Person.testing_create(numericcol=5) Person.testing_create(numericcol=10) g = CTG() totals = g.grand_totals assert totals.something == 15 expected = [ r'^<Grid "CTG">$', r'^No filters$', r'^Totals query ran in \d+\.?\d* seconds$', ] eq_(len(expected), len(m_debug.call_args_list)) for idx, call in enumerate(m_debug.call_args_list): assert_regex(call[0][0], expected[idx])
def setup_class(cls): Status.delete_cascaded() Status.testing_create('pending') Status.testing_create('in process') Status.testing_create('complete') Person.testing_create('bob') Person.testing_create('bob') Person.testing_create()
def setup_module(): Status.delete_cascaded() sp = Status(label='pending') sip = Status(label='in process') sc = Status(label='complete', flag_closed=1) db.session.add_all([sp, sip, sc]) for x in range(1, 5): p = Person() p.firstname = 'fn%03d' % x p.lastname = 'ln%03d' % x p.sortorder = x p.numericcol = '2.13' p.state = 'st%03d' % x if x != 2: p.createdts = dt.datetime(2012, 0o2, 22, 10, x, 16) p.due_date = dt.date(2012, 0o2, x) db.session.add(p) p.emails.append(Email(email='*****@*****.**' % x)) p.emails.append(Email(email='*****@*****.**' % x)) if x % 4 == 1: p.status = sip p.account_type = AccountType.admin elif x % 4 == 2: p.status = sp p.account_type = AccountType.employee elif x % 4 == 0: p.status = None db.session.commit()
def load_db(): from webgrid_ta.model.entities import Status, Person, Email db.create_all() stat_open = Status.add_iu(label=u'open') stat_pending = Status.add_iu(label=u'pending') stat_closed = Status.add_iu(label=u'closed', flag_closed=1) for x in range(1, 50): p = Person() p.firstname = 'fn%03d' % x p.lastname = 'ln%03d' % x p.sortorder = x p.numericcol = D('29.26') * x / D('.9') if x < 90: p.createdts = dt.datetime.now() db.session.add(p) p.emails.append(Email(email='*****@*****.**' % x)) p.emails.append(Email(email='*****@*****.**' % x)) if x % 4 == 1: p.status = stat_open elif x % 4 == 2: p.status = stat_pending elif x % 4 == 0: p.status = None else: p.status = stat_closed db.session.commit()
def setup_module(): Status.delete_cascaded() sp = Status(label='pending') sip = Status(label='in process') sc = Status(label='complete', flag_closed=1) db.session.add_all([sp, sip, sc]) for x in range(1, 5): p = Person() p.firstname = 'fn%03d' % x p.lastname = 'ln%03d' % x p.sortorder = x p.numericcol = '2.13' p.state = 'st%03d' % x if x != 2: p.createdts = dt.datetime(2012, 0o2, 22, 10, x, 16) p.due_date = dt.date(2012, 0o2, x) db.session.add(p) p.emails.append(Email(email='*****@*****.**' % x)) p.emails.append(Email(email='*****@*****.**' % x)) if x % 4 == 1: p.status = sip elif x % 4 == 2: p.status = sp elif x % 4 == 0: p.status = None db.session.commit()