From: Oleg Broytman Date: Mon, 26 Sep 2016 21:53:28 +0000 (+0300) Subject: Rename test_tokens.py -> test_process_tokens.py X-Git-Tag: 0.0.7~3 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=29970ce1d9d4874df8e7ce6d85a4a6fa62337934;p=sqlconvert.git Rename test_tokens.py -> test_process_tokens.py Merge test_stgrouper.py into test_process_tokens.py. --- diff --git a/tests/test_tokens.py b/tests/test_process_tokens.py similarity index 75% rename from tests/test_tokens.py rename to tests/test_process_tokens.py index 4e48ab0..e561667 100644 --- a/tests/test_tokens.py +++ b/tests/test_process_tokens.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- +from pytest import raises from sqlparse import parse from sqlconvert.print_tokens import tlist2str from sqlconvert.process_mysql import remove_directive_tokens, \ is_directive_statement, requote_names, unescape_strings, \ process_statement -from sqlconvert.process_tokens import escape_strings +from sqlconvert.process_tokens import escape_strings, StatementGrouper def test_encoding(): @@ -71,3 +72,23 @@ def test_process(): process_statement(parsed) query = tlist2str(parsed) assert query == u'SELECT * FROM /* test */ "T"' + + +def test_incomplete(): + grouper = StatementGrouper() + grouper.process_line("select * from `T`") + assert not grouper.statements + assert len(grouper.statements) == 0 + raises(ValueError, grouper.close) + + +def test_statements(): + grouper = StatementGrouper() + grouper.process_line("select * from T;") + assert grouper.statements + assert len(grouper.statements) == 1 + for statement in grouper.get_statements(): + query = tlist2str(statement) + assert query == 'SELECT * FROM T;' + assert len(grouper.statements) == 0 + assert grouper.close() is None diff --git a/tests/test_stgrouper.py b/tests/test_stgrouper.py deleted file mode 100644 index 994ef4e..0000000 --- a/tests/test_stgrouper.py +++ /dev/null @@ -1,24 +0,0 @@ - -from pytest import raises -from sqlconvert.print_tokens import tlist2str -from sqlconvert.process_tokens import StatementGrouper - - -def test_incomplete(): - grouper = StatementGrouper() - grouper.process_line("select * from `T`") - assert not grouper.statements - assert len(grouper.statements) == 0 - raises(ValueError, grouper.close) - - -def test_statements(): - grouper = StatementGrouper() - grouper.process_line("select * from T;") - assert grouper.statements - assert len(grouper.statements) == 1 - for statement in grouper.get_statements(): - query = tlist2str(statement) - assert query == 'SELECT * FROM T;' - assert len(grouper.statements) == 0 - assert grouper.close() is None