summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJesús Leganés Combarro "Piranna" <piranna@gmail.com>2012-05-17 23:24:54 +0200
committerJesús Leganés Combarro "Piranna" <piranna@gmail.com>2012-05-17 23:24:54 +0200
commitde8f502cbd54fdac1b91042d414dd99502b5c02b (patch)
tree2d6bdd1673cf3ce86a6187f47355f8375cb6f75d /tests
parent4a41241e8fc084d25cde943263ea507509f9ead4 (diff)
downloadsqlparse-de8f502cbd54fdac1b91042d414dd99502b5c02b.tar.gz
Added compact filter and tests
Diffstat (limited to 'tests')
-rw-r--r--tests/test_functions.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/test_functions.py b/tests/test_functions.py
index 73865a2..f522b35 100644
--- a/tests/test_functions.py
+++ b/tests/test_functions.py
@@ -5,11 +5,13 @@ Created on 13/02/2012
'''
from unittest import main, TestCase
-from sqlparse.lexer import tokenize
+from sqlparse.filters import Tokens2Unicode
+from sqlparse.lexer import tokenize
import sys
sys.path.insert(0, '..')
+from sqlparse.filters import Compact
from sqlparse.functions import GetColumns, GetLimit, IsType
@@ -59,6 +61,29 @@ GROUP BY dir_entries.inode
LIMIT 1"""
+class Test_Compact(Test_SQL):
+ def test_compact1(self):
+ self.assertEqual(Tokens2Unicode(Compact(self.sql, 'tests/files')),
+ 'INSERT INTO dir_entries(type)VALUES(:type);INSERT INTO '
+ 'directories(inode)VALUES(:inode)LIMIT 1')
+
+ def test_compact2(self):
+ self.assertEqual(Tokens2Unicode(Compact(self.sql2)),
+ 'SELECT child_entry,asdf AS inode,creation FROM links WHERE '
+ 'parent_dir==:parent_dir AND name==:name LIMIT 1')
+
+ def test_compact3(self):
+ self.assertEqual(Tokens2Unicode(Compact(self.sql3)),
+ 'SELECT 0 AS st_dev,0 AS st_uid,0 AS st_gid,dir_entries.type AS '
+ 'st_mode,dir_entries.inode AS st_ino,COUNT(links.child_entry)AS '
+ 'st_nlink,:creation AS st_ctime,dir_entries.access AS st_atime,'
+ 'dir_entries.modification AS st_mtime,COALESCE(files.size,0)AS '
+ 'st_size,COALESCE(files.size,0)AS size FROM dir_entries LEFT JOIN'
+ ' files ON dir_entries.inode==files.inode LEFT JOIN links ON '
+ 'dir_entries.inode==links.child_entry WHERE dir_entries.inode=='
+ ':inode GROUP BY dir_entries.inode LIMIT 1')
+
+
class Test_GetColumns(Test_SQL):
def test_getcolumns1(self):
columns = GetColumns(tokenize(self.sql))