old_contents: import json
  import unittest
  
  from raco.myrialang import compile_to_json
  import raco.fakedb
  import raco.myrial.interpreter as interpreter
  import raco.myrial.parser as parser
  
  
  class MyrialTestCase(unittest.TestCase):
  
      def setUp(self):
          self.db = raco.fakedb.FakeDatabase()
          self.parser = parser.Parser()
          self.processor = interpreter.StatementProcessor(self.db)
  
      def parse(self, query):
          '''Parse a query'''
          statements = self.parser.parse(query)
          self.processor.evaluate(statements)
  
      def get_plan(self, query, logical=False):
          '''Get the MyriaL query plan for a query'''
          statements = self.parser.parse(query)
          self.processor.evaluate(statements)
          if logical:
              return self.processor.get_logical_plan()
          else:
              return self.processor.get_physical_plan()
  
      def get_logical_plan(self, query):
          '''Get the logical plan for a MyriaL query'''
          return self.get_plan(query, True)
  
      def get_physical_plan(self, query):
          '''Get the physical plan for a MyriaL query'''
          return self.get_plan(query, False)
  
      def execute_query(self, query, test_logical=False, skip_json=False,
                        output='OUTPUT'):
          '''Run a test query against the fake database'''
          plan = self.get_plan(query, test_logical)
  
          if not test_logical and not skip_json:
              # Test that JSON compilation runs without error
              # TODO: verify the JSON output somehow?
              json_string = json.dumps(compile_to_json(
                  "some query", "some logical plan", plan, self.db))
              assert json_string
  
          self.db.evaluate(plan)
  
          return self.db.get_table(output)
  
      def check_result(self, query, expected, test_logical=False,
                       skip_json=False, output='OUTPUT', scheme=None):
          '''Execute a test query with an expected output'''
          actual = self.execute_query(query, test_logical, skip_json, output)
          self.assertEquals(actual, expected)
          if scheme:
              self.assertEquals(self.db.get_scheme(output), scheme)
  
      def check_scheme(self, query, scheme):
          '''Execute a test query with an expected output schema.'''
          actual = self.execute_query(query)
          self.assertEquals(self.db.get_scheme('OUTPUT'), scheme)
  
new_contents: import json
  import unittest
  
  from raco.myrialang import compile_to_json
  import raco.fakedb
  import raco.myrial.interpreter as interpreter
  import raco.myrial.parser as parser
  
  
  class MyrialTestCase(unittest.TestCase):
  
      def setUp(self):
          self.db = raco.fakedb.FakeDatabase()
          self.parser = parser.Parser()
          self.processor = interpreter.StatementProcessor(self.db)
  
      def parse(self, query):
          '''Parse a query'''
          statements = self.parser.parse(query)
          self.processor.evaluate(statements)
  
      def get_plan(self, query, logical=False):
          '''Get the MyriaL query plan for a query'''
          statements = self.parser.parse(query)
          self.processor.evaluate(statements)
          if logical:
              p = self.processor.get_logical_plan()
          else:
              p = self.processor.get_physical_plan()
          # verify that we can stringify p
          # TODO verify the string somehow?
          assert str(p)
          return p
  
      def get_logical_plan(self, query):
          '''Get the logical plan for a MyriaL query'''
          return self.get_plan(query, True)
  
      def get_physical_plan(self, query):
          '''Get the physical plan for a MyriaL query'''
          return self.get_plan(query, False)
  
      def execute_query(self, query, test_logical=False, skip_json=False,
                        output='OUTPUT'):
          '''Run a test query against the fake database'''
          plan = self.get_plan(query, test_logical)
  
          if not test_logical and not skip_json:
              # Test that JSON compilation runs without error
              # TODO: verify the JSON output somehow?
              json_string = json.dumps(compile_to_json(
                  "some query", "some logical plan", plan, self.db))
              assert json_string
  
          self.db.evaluate(plan)
  
          return self.db.get_table(output)
  
      def check_result(self, query, expected, test_logical=False,
                       skip_json=False, output='OUTPUT', scheme=None):
          '''Execute a test query with an expected output'''
          actual = self.execute_query(query, test_logical, skip_json, output)
          self.assertEquals(actual, expected)
          if scheme:
              self.assertEquals(self.db.get_scheme(output), scheme)
  
      def check_scheme(self, query, scheme):
          '''Execute a test query with an expected output schema.'''
          actual = self.execute_query(query)
          self.assertEquals(self.db.get_scheme('OUTPUT'), scheme)
  
subject: verify that plans can be stringified