Skip to content

Commit cdfbac8

Browse files
committed
Unit Test for selecting tables in date range
1 parent c25ead6 commit cdfbac8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

bigquery/tests/test_query_builder.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ def test_no_dataset(self):
8080

8181
self.assertEqual(result, 'FROM [.man], [.pig], [.bro]')
8282

83+
def test_tables_in_date_range(self):
84+
"""Ensure that render sources can handle tables in DATE RANGE."""
85+
from bigquery.query_builder import _render_sources
86+
87+
tables = {
88+
'date_range': True,
89+
'from_date': '2015-08-23',
90+
'to_date': '2015-10-10',
91+
'table': 'pets_'
92+
}
93+
94+
result = _render_sources('animals', tables)
95+
96+
self.assertEqual(result, "FROM (TABLE_DATE_RANGE([animals.pets_], "
97+
"TIMESTAMP('2015-08-23'), TIMESTAMP('2015-10-10'))) ")
98+
8399

84100
class TestRenderConditions(unittest.TestCase):
85101

0 commit comments

Comments
 (0)