def test_math(): result = compute(sin(t.amount), s) assert normalize(str(result)) == normalize(""" SELECT sin(accounts.amount) as amount FROM accounts""") result = compute(floor(t.amount), s) assert normalize(str(result)) == normalize(""" SELECT floor(accounts.amount) as amount FROM accounts""") result = compute(t.amount // 2, s) assert normalize(str(result)) == normalize(""" SELECT floor(accounts.amount / :amount_1) AS amount FROM accounts""")
def test_floor_ceil(bank): t = symbol('t', discover(bank)) assert set(compute(200 * floor(t.amount / 200), bank)) == set([0, 200]) assert set(compute(200 * ceil(t.amount / 200), bank)) == set([200, 400])