From 4caa5c1412fef9c4bddb792cb59063ae9d0321da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s=20Combarro=20=22Piranna?= Date: Wed, 23 May 2012 18:20:07 +0200 Subject: Updated tests --- tests/test_functions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/test_functions.py b/tests/test_functions.py index 1a7ec18..d5d8f91 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -11,7 +11,7 @@ from sqlparse.lexer import tokenize import sys sys.path.insert(0, '..') -from sqlparse.filters import Compact +from sqlparse.filters import compact from sqlparse.functions import getcolumns, getlimit, IsType @@ -63,17 +63,17 @@ LIMIT 1""" class Test_Compact(Test_SQL): def test_compact1(self): - self.assertEqual(Tokens2Unicode(Compact(self.sql, 'tests/files')), + 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)), + 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)), + 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,' -- cgit v1.2.1 From 482d6164a5d0e8f01dbf5b6c6d059763bf6d1eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s=20Combarro=20=22Piranna?= Date: Wed, 23 May 2012 18:49:46 +0200 Subject: Fixed some tests --- tests/test_functions.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test_functions.py b/tests/test_functions.py index d5d8f91..5ab1586 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -63,17 +63,29 @@ LIMIT 1""" class Test_Compact(Test_SQL): def test_compact1(self): - self.assertEqual(Tokens2Unicode(compact(self.sql, 'tests/files')), + stream = compact(tokenize(self.sql), 'tests/files') + + result = Tokens2Unicode(stream) + + self.assertEqual(result, '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)), + stream = tokenize(self.sql2) + + result = compact(stream) + + self.assertEqual(Tokens2Unicode(result), '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)), + stream = tokenize(self.sql3) + + result = compact(stream) + + self.assertEqual(Tokens2Unicode(result), '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,' -- cgit v1.2.1 From df7a0d01259b772b199eab042989f14e8a04d5fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s=20Combarro=20=22Piranna?= Date: Wed, 23 May 2012 18:52:55 +0200 Subject: Fixed 'compact' tests --- tests/test_functions.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/test_functions.py b/tests/test_functions.py index 5ab1586..ff8625a 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -15,7 +15,7 @@ from sqlparse.filters import compact from sqlparse.functions import getcolumns, getlimit, IsType -class Test_SQL(TestCase): +class Test_IncludeStatement(TestCase): sql = """-- type: script -- return: integer @@ -25,6 +25,24 @@ class Test_SQL(TestCase): VALUES(:inode) LIMIT 1""" + def test_includeStatement(self): + stream = compact(tokenize(self.sql), 'tests/files') + + result = Tokens2Unicode(stream) + + self.assertEqual(result, + 'INSERT INTO dir_entries(type)VALUES(:type);INSERT INTO ' + 'directories(inode)VALUES(:inode)LIMIT 1') + + +class Test_SQL(TestCase): + sql = """-- type: script + -- return: integer + + INSERT INTO directories(inode) + VALUES(:inode) + LIMIT 1""" + sql2 = """SELECT child_entry,asdf AS inode, creation FROM links WHERE parent_dir == :parent_dir AND name == :name @@ -63,13 +81,12 @@ LIMIT 1""" class Test_Compact(Test_SQL): def test_compact1(self): - stream = compact(tokenize(self.sql), 'tests/files') + stream = compact(tokenize(self.sql)) result = Tokens2Unicode(stream) self.assertEqual(result, - 'INSERT INTO dir_entries(type)VALUES(:type);INSERT INTO ' - 'directories(inode)VALUES(:inode)LIMIT 1') + 'INSERT INTO directories(inode)VALUES(:inode)LIMIT 1') def test_compact2(self): stream = tokenize(self.sql2) -- cgit v1.2.1 From 564d5f33c5a12f6ffab449a82703550037c6d6a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s=20Combarro=20=22Piranna?= Date: Wed, 23 May 2012 18:57:43 +0200 Subject: Finished test for IncludeStatement --- tests/test_functions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_functions.py b/tests/test_functions.py index ff8625a..1d2be9c 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -5,7 +5,7 @@ Created on 13/02/2012 ''' from unittest import main, TestCase -from sqlparse.filters import Tokens2Unicode +from sqlparse.filters import IncludeStatement, Tokens2Unicode from sqlparse.lexer import tokenize import sys @@ -26,7 +26,10 @@ class Test_IncludeStatement(TestCase): LIMIT 1""" def test_includeStatement(self): - stream = compact(tokenize(self.sql), 'tests/files') + stream = tokenize(self.sql) + includeStatement = IncludeStatement('tests/files') + stream = includeStatement.process(None, stream) + stream = compact(stream) result = Tokens2Unicode(stream) -- cgit v1.2.1 From a18c97f796737b9a8ec57e56e185dead9b6e881a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s=20Combarro=20=22Piranna?= Date: Wed, 23 May 2012 19:02:48 +0200 Subject: Fixed test_includeStatement --- tests/test_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_functions.py b/tests/test_functions.py index 1d2be9c..aa382ce 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -27,7 +27,7 @@ class Test_IncludeStatement(TestCase): def test_includeStatement(self): stream = tokenize(self.sql) - includeStatement = IncludeStatement('tests/files') + includeStatement = IncludeStatement('tests/files', raiseexceptions=True) stream = includeStatement.process(None, stream) stream = compact(stream) -- cgit v1.2.1