def test_print_with_no_filter(self): statement = qc.EvalPrint(qc.EvalFrom(None, None, None, None)) oss = io.StringIO() qx.execute_print(statement, self.entries, self.options_map, oss) self.assertEqualEntries(self.INPUT, oss.getvalue()) statement = qc.EvalPrint(None) oss = io.StringIO() qx.execute_print(statement, self.entries, self.options_map, oss) self.assertEqualEntries(self.INPUT, oss.getvalue())
def test_compile_from(self): # Test the compilation of from. query = self.compile("SELECT account;") self.assertEqual(None, query.c_from) query = self.compile("SELECT account FROM CLOSE;") self.assertEqual(qc.EvalFrom(None, None, True, None), query.c_from) query = self.compile("SELECT account FROM length(payee) != 0;") self.assertTrue(isinstance(query.c_from, qc.EvalFrom)) self.assertTrue(isinstance(query.c_from.c_expr, qc.EvalNode)) with self.assertRaises(qc.CompilationError): query = self.compile("SELECT account FROM sum(payee) != 0;")
def test_print_with_filter(self): statement = qc.EvalPrint(qc.EvalFrom(qc.EvalEqual(qe.YearEntryColumn(), qc.EvalConstant(2012)), None, None, None)) oss = io.StringIO() qx.execute_print(statement, self.entries, self.options_map, oss) self.assertEqualEntries(""" 2012-02-02 * "Dinner with Dos" Assets:Bank:Checking 102.00 USD Expenses:Restaurant -102.00 USD """, oss.getvalue())
def test_print_from(self): self.assertCompile( qc.EvalPrint( qc.EvalFrom( qc.EvalEqual(qe.YearEntryColumn(), qc.EvalConstant(2014)), None, None, None)), "PRINT FROM year = 2014;")