Ejemplo n.º 1
0
    def check_query(self,
                    input_string, bql_string,
                    expected_types, expected_rows,
                    sort_rows=False,
                    debug=False):

        entries, _, options_map = loader.load_string(input_string)
        query = self.compile(bql_string)
        result_types, result_rows = qx.execute_query(query, entries, options_map)

        if debug:
            with misc_utils.box('result_types'):
                print(result_types)
            with misc_utils.box('result_rows'):
                print(result_rows)
        self.assertEqual(expected_types, result_types)
        if sort_rows:
            result_rows.sort()
        self.assertEqual(expected_rows, result_rows)
Ejemplo n.º 2
0
    def test_box(self):
        with test_utils.capture() as stdout:
            with misc_utils.box():
                print('A')
        self.assertEqual(
            textwrap.dedent("""
          ,----------------
          A
          `----------------
        """), stdout.getvalue())

        with test_utils.capture() as stdout:
            with misc_utils.box('entries'):
                print('A')
        self.assertEqual(
            textwrap.dedent("""
          ,--------(entries)--------
          A
          `-------------------------
        """), stdout.getvalue())