-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from dorosch/resolve/5
Added support of chunk_time_interval parameter
- Loading branch information
Showing
3 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pytest | ||
from sqlalchemy import DDL | ||
|
||
from sqlalchemy_timescaledb.dialect import TimescaledbDDLCompiler | ||
|
||
|
||
class TestTimescaledbDDLCompiler: | ||
def test_default_params(self): | ||
assert TimescaledbDDLCompiler.ddl_hypertable( | ||
'test', {'time_column_name': 'timestamp'} | ||
).compile().string == DDL( | ||
f""" | ||
SELECT create_hypertable( | ||
'test', | ||
'timestamp', | ||
chunk_time_interval => INTERVAL '7 days', | ||
if_not_exists => TRUE | ||
); | ||
""" | ||
).compile().string | ||
|
||
@pytest.mark.parametrize('interval,expected', [ | ||
('1 days', "INTERVAL '1 days'"), | ||
('7 hour', "INTERVAL '7 hour'"), | ||
(86400, 86400), | ||
('86400', 86400) | ||
]) | ||
def test_chunk_time_interval(self, interval, expected): | ||
assert TimescaledbDDLCompiler.ddl_hypertable( | ||
'test', { | ||
'time_column_name': 'timestamp', | ||
'chunk_time_interval': interval | ||
} | ||
).compile().string == DDL( | ||
f""" | ||
SELECT create_hypertable( | ||
'test', | ||
'timestamp', | ||
chunk_time_interval => {expected}, | ||
if_not_exists => TRUE | ||
); | ||
""" | ||
).compile().string |