|
11 | 11 | from riak.table import Table |
12 | 12 | from riak.ts_object import TsObject |
13 | 13 | from riak.codecs.ttb import TtbCodec |
14 | | -from riak.util import str_to_bytes, \ |
| 14 | +from riak.util import str_to_bytes, bytes_to_str, \ |
15 | 15 | unix_time_millis, is_timeseries_supported |
16 | 16 | from riak.tests import RUN_TIMESERIES |
17 | 17 | from riak.tests.base import IntegrationTestBase |
@@ -141,7 +141,7 @@ def test_query_that_returns_table_description(self): |
141 | 141 | row = ts_obj.rows[0] |
142 | 142 | self.assertEqual(len(row), 5) |
143 | 143 |
|
144 | | - def test_store_and_fetch(self): |
| 144 | + def test_store_and_fetch_and_query(self): |
145 | 145 | now = datetime.datetime.utcfromtimestamp(144379690.987000) |
146 | 146 | fiveMinsAgo = now - fiveMins |
147 | 147 | tenMinsAgo = fiveMinsAgo - fiveMins |
@@ -187,6 +187,29 @@ def test_store_and_fetch(self): |
187 | 187 | self.assertEqual(len(row), 5) |
188 | 188 | self.assertEqual(row, exp) |
189 | 189 |
|
| 190 | + fmt = """ |
| 191 | + select * from {table} where |
| 192 | + time > {t1} and time < {t2} and |
| 193 | + geohash = 'hash1' and |
| 194 | + user = 'user2' |
| 195 | + """ |
| 196 | + query = fmt.format( |
| 197 | + table=table_name, |
| 198 | + t1=unix_time_millis(tenMinsAgo), |
| 199 | + t2=unix_time_millis(now)) |
| 200 | + ts_obj = self.client.ts_query(table_name, query) |
| 201 | + if ts_obj.columns is not None: |
| 202 | + self.assertEqual(len(ts_obj.columns.names), 5) |
| 203 | + self.assertEqual(len(ts_obj.columns.types), 5) |
| 204 | + self.assertEqual(len(ts_obj.rows), 1) |
| 205 | + row = ts_obj.rows[0] |
| 206 | + self.assertEqual(bytes_to_str(row[0]), 'hash1') |
| 207 | + self.assertEqual(bytes_to_str(row[1]), 'user2') |
| 208 | + self.assertEqual(row[2], fiveMinsAgo) |
| 209 | + self.assertEqual(row[2].microsecond, 987000) |
| 210 | + self.assertEqual(bytes_to_str(row[3]), 'wind') |
| 211 | + self.assertIsNone(row[4]) |
| 212 | + |
190 | 213 | def test_create_error_via_put(self): |
191 | 214 | table = Table(self.client, table_name) |
192 | 215 | ts_obj = table.new([]) |
|
0 commit comments