Commits

Olemis Lang committed ab44924

GViz QL : Asserting correct behavior if wrong column name is supplied

  • Participants
  • Parent commits 279c2ca
  • Branches gviz_ql

Comments (0)

Files changed (2)

File trac-dev/gviz/tracgviz/gvizql.py

     else:
       raise GVizRuntimeError("Format not supported for %s type" % (coltype,))
 
-  def _formatter(self, col, pattern):
+  def _formatter(self, colnm, col, pattern):
     if col is None:
       raise LookupError("Unknown column '%s'" % (colnm,))
-    colnm, coltype = col[:2]
+    coltype = col[1]
     if coltype == 'boolean':
       pattern = pattern.rsplit(':', 1)
       if len(pattern) != 2:
     to transform data set into (value, formatted_value) tuples.
     """
     cols = dict([col[0], col] for col in schema)
-    patterns = dict([colnm, self._formatter(cols.get(colnm), p)] \
+    patterns = dict([colnm, self._formatter(colnm, cols.get(colnm), p)] \
         for colnm, p in self.fmt)
 
     #raise ValueError('\n'.join([str(patterns), str(schema), str(list(data))]))

File trac-dev/gviz/tracgviz/testing/test_gvizql.py

       Import hack not needed any more . Back to normal
       >>> del sys.modules['PyICU']
       """,
+  'Parsing FORMAT (errors)' : r"""
+      >>> parse("format done '##0.0'", 'fmt')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved format
+      Token.Name.Variable done
+      Token.Literal.String.Single '##0.0'
+      *****
+      * Parsing
+      *****
+      [('done', '##0.0')]
+      *****
+      * Result
+      *****
+      LookupError  :  Unknown column 'done'
+
+      >>> parse(r'''select name, done, total - done '''
+      ...       '''format `total - done` '#,##0.0' ''', 'fmt')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Variable name
+      Token.Punctuation ,
+      Token.Name.Variable done
+      Token.Punctuation ,
+      Token.Name.Variable total
+      Token.Operator.Arithmetic -
+      Token.Name.Variable done
+      Token.Keyword.Reserved format
+      Token.Name.Variable `total - done`
+      Token.Literal.String.Single '#,##0.0'
+      *****
+      * Parsing
+      *****
+      [('total - done', '#,##0.0')]
+      *****
+      * Result
+      *****
+      GVizRuntimeError  :  Unknown column done.
+
+      """,
   'Parsing FORMAT (simple)' : r"""
       >>> parse("  format  salary   '#,##0.00' ", 'fmt')
       *****