@@ -249,6 +249,107 @@ def test_to_pb(self):
249249 self .assertEqual (pb_val , expected_pb )
250250
251251
252+ class TestValueRangeFilter (unittest2 .TestCase ):
253+
254+ def _getTargetClass (self ):
255+ from gcloud .bigtable .row import ValueRangeFilter
256+ return ValueRangeFilter
257+
258+ def _makeOne (self , * args , ** kwargs ):
259+ return self ._getTargetClass ()(* args , ** kwargs )
260+
261+ def test_constructor_defaults (self ):
262+ row_filter = self ._makeOne ()
263+ self .assertEqual (row_filter .start_value , None )
264+ self .assertEqual (row_filter .end_value , None )
265+ self .assertTrue (row_filter .inclusive_start )
266+ self .assertTrue (row_filter .inclusive_end )
267+
268+ def test_constructor_explicit (self ):
269+ start_value = object ()
270+ end_value = object ()
271+ inclusive_start = object ()
272+ inclusive_end = object ()
273+ row_filter = self ._makeOne (start_value = start_value ,
274+ end_value = end_value ,
275+ inclusive_start = inclusive_start ,
276+ inclusive_end = inclusive_end )
277+ self .assertTrue (row_filter .start_value is start_value )
278+ self .assertTrue (row_filter .end_value is end_value )
279+ self .assertTrue (row_filter .inclusive_start is inclusive_start )
280+ self .assertTrue (row_filter .inclusive_end is inclusive_end )
281+
282+ def test_constructor_bad_start (self ):
283+ self .assertRaises (ValueError , self ._makeOne , inclusive_start = True )
284+
285+ def test_constructor_bad_end (self ):
286+ self .assertRaises (ValueError , self ._makeOne , inclusive_end = True )
287+
288+ def test___eq__ (self ):
289+ start_value = object ()
290+ end_value = object ()
291+ inclusive_start = object ()
292+ inclusive_end = object ()
293+ row_filter1 = self ._makeOne (start_value = start_value ,
294+ end_value = end_value ,
295+ inclusive_start = inclusive_start ,
296+ inclusive_end = inclusive_end )
297+ row_filter2 = self ._makeOne (start_value = start_value ,
298+ end_value = end_value ,
299+ inclusive_start = inclusive_start ,
300+ inclusive_end = inclusive_end )
301+ self .assertEqual (row_filter1 , row_filter2 )
302+
303+ def test___eq__type_differ (self ):
304+ row_filter1 = self ._makeOne ()
305+ row_filter2 = object ()
306+ self .assertNotEqual (row_filter1 , row_filter2 )
307+
308+ def test_to_pb (self ):
309+ from gcloud .bigtable ._generated import bigtable_data_pb2 as data_pb2
310+
311+ row_filter = self ._makeOne ()
312+ expected_pb = data_pb2 .RowFilter (
313+ value_range_filter = data_pb2 .ValueRange ())
314+ self .assertEqual (row_filter .to_pb (), expected_pb )
315+
316+ def test_to_pb_inclusive_start (self ):
317+ from gcloud .bigtable ._generated import bigtable_data_pb2 as data_pb2
318+
319+ value = b'some-value'
320+ row_filter = self ._makeOne (start_value = value )
321+ val_range_pb = data_pb2 .ValueRange (start_value_inclusive = value )
322+ expected_pb = data_pb2 .RowFilter (value_range_filter = val_range_pb )
323+ self .assertEqual (row_filter .to_pb (), expected_pb )
324+
325+ def test_to_pb_exclusive_start (self ):
326+ from gcloud .bigtable ._generated import bigtable_data_pb2 as data_pb2
327+
328+ value = b'some-value'
329+ row_filter = self ._makeOne (start_value = value , inclusive_start = False )
330+ val_range_pb = data_pb2 .ValueRange (start_value_exclusive = value )
331+ expected_pb = data_pb2 .RowFilter (value_range_filter = val_range_pb )
332+ self .assertEqual (row_filter .to_pb (), expected_pb )
333+
334+ def test_to_pb_inclusive_end (self ):
335+ from gcloud .bigtable ._generated import bigtable_data_pb2 as data_pb2
336+
337+ value = b'some-value'
338+ row_filter = self ._makeOne (end_value = value )
339+ val_range_pb = data_pb2 .ValueRange (end_value_inclusive = value )
340+ expected_pb = data_pb2 .RowFilter (value_range_filter = val_range_pb )
341+ self .assertEqual (row_filter .to_pb (), expected_pb )
342+
343+ def test_to_pb_exclusive_end (self ):
344+ from gcloud .bigtable ._generated import bigtable_data_pb2 as data_pb2
345+
346+ value = b'some-value'
347+ row_filter = self ._makeOne (end_value = value , inclusive_end = False )
348+ val_range_pb = data_pb2 .ValueRange (end_value_exclusive = value )
349+ expected_pb = data_pb2 .RowFilter (value_range_filter = val_range_pb )
350+ self .assertEqual (row_filter .to_pb (), expected_pb )
351+
352+
252353class Test_CellCountFilter (unittest2 .TestCase ):
253354
254355 def _getTargetClass (self ):
0 commit comments