Skip to content

Commit 4a6f92d

Browse files
add tests for invalid inputs
1 parent 64b6090 commit 4a6f92d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

rbc/tests/heavydb/test_daytimeinterval.py

+34
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
from rbc.tests import heavydb_fixture
3+
from rbc.errors import HeavyDBServerError
34

45
rbc_heavydb = pytest.importorskip("rbc.heavydb")
56
available_version, reason = rbc_heavydb.is_available()
@@ -154,3 +155,36 @@ def test_generate_time_series(heavydb, start, stop, step, order):
154155
_, rbc_result = heavydb.sql_execute(non_named_arg_query.format(RBC_FUNC))
155156
_, heavy_result = heavydb.sql_execute(non_named_arg_query.format(HEAVYDB_FUNC))
156157
assert list(rbc_result) == list(heavy_result)
158+
159+
160+
invalid_inputs = [
161+
(
162+
# Step of 0 days is not permitted
163+
"TIMESTAMP(9) '1970-01-01 00:00:00.000000010'",
164+
"TIMESTAMP(9) '1970-01-01 00:00:00.000000020'",
165+
"INTERVAL '0' day",
166+
"Timestamp division by zero",
167+
),
168+
(
169+
# Step of 0 months is not permitted
170+
"TIMESTAMP(9) '1970-01-01 00:00:00.000000010'",
171+
"TIMESTAMP(9) '1970-01-01 00:00:00.000000020'",
172+
"INTERVAL '0' month",
173+
"Timestamp division by zero",
174+
),
175+
]
176+
177+
178+
@pytest.mark.parametrize("start, stop, step, error_msg", invalid_inputs)
179+
def test_generate_series_invalid_inputs(heavydb, start, stop, step, error_msg):
180+
181+
query = (
182+
"SELECT generate_series FROM TABLE(rbc_generate_series("
183+
f"{start},"
184+
f"{stop},"
185+
f"{step}));"
186+
)
187+
with pytest.raises(HeavyDBServerError) as exc:
188+
_, result = heavydb.sql_execute(query)
189+
190+
assert exc.match(error_msg)

0 commit comments

Comments
 (0)