Skip to content

Commit 2eb2457

Browse files
committed
uncomment other tests, pass error type as parameter
1 parent a3d10f6 commit 2eb2457

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

src/queryparser/testing/test_postgresql.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@
1414
tests = yaml.load(f, Loader=yaml.FullLoader)
1515

1616

17-
# @pytest.mark.parametrize("t", tests['common_tests'])
18-
# def test_postgresql_parsing_common(t):
19-
# _test_parsing(PostgreSQLQueryProcessor, t)
17+
@pytest.mark.parametrize('t', tests['common_tests'])
18+
def test_postgresql_parsing_common(t):
19+
_test_parsing(PostgreSQLQueryProcessor, t)
2020

2121

22-
# @pytest.mark.parametrize('t', tests['postgresql_tests'])
23-
# def test_postgresql_parsing(t):
24-
# _test_parsing(PostgreSQLQueryProcessor, t)
22+
@pytest.mark.parametrize('t', tests['postgresql_tests'])
23+
def test_postgresql_parsing(t):
24+
_test_parsing(PostgreSQLQueryProcessor, t)
2525

2626

27-
# @pytest.mark.parametrize("t", tests['common_syntax_tests'])
28-
# def test_postgresql_syntax(t):
29-
# with pytest.raises(QuerySyntaxError):
30-
# PostgreSQLQueryProcessor(t)
27+
@pytest.mark.parametrize('t', tests['common_syntax_tests'])
28+
def test_postgresql_syntax(t):
29+
with pytest.raises(QuerySyntaxError):
30+
PostgreSQLQueryProcessor(t)
3131

3232

33-
# @pytest.mark.parametrize("t", tests['common_query_tests'])
34-
# def test_postrgresql_query(t):
35-
# with pytest.raises(QueryError):
36-
# PostgreSQLQueryProcessor(t)
33+
@pytest.mark.parametrize('t', tests['common_query_tests'])
34+
def test_postrgresql_query(t):
35+
with pytest.raises(QueryError):
36+
PostgreSQLQueryProcessor(t)
3737

3838

3939
@pytest.mark.parametrize('t', tests['postgresql_failure_tests'])

src/queryparser/testing/tests.yaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -829,31 +829,40 @@ postgresql_tests:
829829
-
830830

831831
-
832-
- "SELECT specuid, ra, dec FROM dr1.spectrum WHERE QMOST_SPEC_IS_IN_SURVEY(specuid, '04');"
832+
- SELECT specuid, ra, dec FROM dr1.spectrum WHERE QMOST_SPEC_IS_IN_SURVEY(specuid, '04');
833833
- ['dr1.spectrum.specuid', 'dr1.spectrum.ra', 'dr1.spectrum.dec']
834-
- ["where"]
835-
- ["QMOST_SPEC_IS_IN_SURVEY"]
836-
- ["specuid: dr1.spectrum.specuid", "ra: dr1.spectrum.ra", "dec: dr1.spectrum.dec"]
837-
- ["dr1.spectrum"]
834+
- [where]
835+
- [QMOST_SPEC_IS_IN_SURVEY]
836+
- ['specuid: dr1.spectrum.specuid', 'ra: dr1.spectrum.ra', 'dec: dr1.spectrum.dec']
837+
- [dr1.spectrum]
838838
-
839-
- ["QMOST_SPEC_IS_IN_SURVEY"]
839+
- [QMOST_SPEC_IS_IN_SURVEY]
840840

841841
postgresql_failure_tests:
842842
-
843843
- SELECT specuid, ra, dec FROM dr1.spectrum WHERE QMOST_SPEC_IS_IN_SURVEY(specuid, '04');
844+
- syntax
844845
-
845846
- []
846847

847848
-
848849
- SELECT specuid, ra, dec FROM dr1.spectrum WHERE BLA(specuid, '04');
850+
- syntax
849851
-
850852
- [QMOST_SPEC_IS_IN_SURVEY]
851853

852854
-
853855
- SELECT specuid, ra, dec FROM dr1.spectrum WHERE QMOST_SPEC_IS_IN_SURVEY[specuid, '04'];
856+
- syntax
854857
-
855858
- [QMOST_SPEC_IS_IN_SURVEY]
856859

860+
-
861+
- SELECT specuid, ra, dec FROM dr1.spectrum WHERE a(specuid, '04');
862+
- value
863+
-
864+
- [a, b, c, d, e, f, g, h, i, j, k, l]
865+
857866

858867
adql_mysql_tests:
859868
-

src/queryparser/testing/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ def _test_parsing(query_processor, test, translate=False):
8181

8282

8383
def _test_failure_parsing(query_processor, test, translate=False):
84-
query, replace_schema_name, replace_function_names = test
84+
query, errortype, replace_schema_name, replace_function_names = test
85+
86+
if errortype == 'syntax':
87+
e = QuerySyntaxError
88+
elif errortype == 'value':
89+
e = ValueError
8590

8691
if translate:
8792
adt = ADQLQueryTranslator()
@@ -94,7 +99,7 @@ def _test_failure_parsing(query_processor, test, translate=False):
9499
qp = query_processor()
95100
qp.set_query(query)
96101

97-
with pytest.raises(QuerySyntaxError):
102+
with pytest.raises(e):
98103
qp.process_query(
99104
replace_schema_name=replace_schema_name,
100105
replace_function_names=replace_function_names,

0 commit comments

Comments
 (0)