@@ -279,6 +279,68 @@ def test_row_range_get_range_kwargs_open_closed():
279279 assert expected_result == actual_result
280280
281281
282+ def test_row_range_get_range_kwargs_unbounded_start ():
283+ from google .cloud .bigtable .row_set import RowRange
284+
285+ end_key = b"row_key9"
286+ expected_result = {"end_key_open" : end_key }
287+ row_range = RowRange (None , end_key )
288+ actual_result = row_range .get_range_kwargs ()
289+ assert expected_result == actual_result
290+
291+
292+ def test_row_range_get_range_kwargs_unbounded_end ():
293+ from google .cloud .bigtable .row_set import RowRange
294+
295+ start_key = b"row_key1"
296+ expected_result = {"start_key_closed" : start_key }
297+ row_range = RowRange (start_key , None )
298+ actual_result = row_range .get_range_kwargs ()
299+ assert expected_result == actual_result
300+
301+
302+ def test_mappable_attributes_mixin_guard_recursion ():
303+ import pytest
304+
305+ from google .cloud .bigtable .helpers import _MappableAttributesMixin
306+
307+ class Uninitialized (_MappableAttributesMixin ):
308+ pass
309+
310+ obj = Uninitialized ()
311+ with pytest .raises (AttributeError ):
312+ _ = obj ._attribute_map
313+ with pytest .raises (AttributeError ):
314+ _ = obj .non_existent_attribute
315+
316+ # Verify setattr on _attribute_map doesn't cause recursion
317+ obj ._attribute_map = {"old_attr" : "new_attr" }
318+ assert obj ._attribute_map == {"old_attr" : "new_attr" }
319+
320+
321+ def test_mappable_attributes_mixin_remap ():
322+ import pytest
323+
324+ from google .cloud .bigtable .helpers import _MappableAttributesMixin
325+
326+ class DummyBase :
327+ def __init__ (self , target_attr = None ):
328+ self .target_attr = target_attr
329+
330+ class MappedClass (_MappableAttributesMixin , DummyBase ):
331+ _attribute_map = {"source_attr" : "target_attr" }
332+
333+ instance = MappedClass (source_attr = "hello" )
334+ assert instance .target_attr == "hello"
335+ assert instance .source_attr == "hello"
336+
337+ instance .source_attr = "world"
338+ assert instance .target_attr == "world"
339+
340+ with pytest .raises (AttributeError ):
341+ _ = instance .unknown_attr
342+
343+
282344def _ReadRowsRequestPB (* args , ** kw ):
283345 from google .cloud .bigtable_v2 .types import bigtable as messages_v2_pb2
284346
0 commit comments