def test__filter_row_ranges_all_ranges_already_read_open_closed(self): last_scanned_key = b"row_key54" row_range1 = RowRange(b"row_key21", b"row_key29", False, True) row_range2 = RowRange(b"row_key31", b"row_key39") row_range3 = RowRange(b"row_key41", b"row_key49", False, True) request = _ReadRowsRequestPB(table_name=self.table_name) request.rows.row_ranges.add(**row_range1.get_range_kwargs()) request.rows.row_ranges.add(**row_range2.get_range_kwargs()) request.rows.row_ranges.add(**row_range3.get_range_kwargs()) request_manager = self._make_one(request, last_scanned_key, 2) request_manager.new_message = _ReadRowsRequestPB(table_name=self.table_name) row_ranges = request_manager._filter_row_ranges() self.assertEqual(row_ranges, [])
def test__filter_row_ranges_all_ranges_already_read_open_closed(self): last_scanned_key = b"row_key54" row_range1 = RowRange(b"row_key21", b"row_key29", False, True) row_range2 = RowRange(b"row_key31", b"row_key39") row_range3 = RowRange(b"row_key41", b"row_key49", False, True) request = _ReadRowsRequestPB(table_name=self.table_name) request.rows.row_ranges.add(**row_range1.get_range_kwargs()) request.rows.row_ranges.add(**row_range2.get_range_kwargs()) request.rows.row_ranges.add(**row_range3.get_range_kwargs()) request_manager = self._make_one(request, last_scanned_key, 2) request_manager.new_message = _ReadRowsRequestPB(table_name=self.table_name) row_ranges = request_manager._filter_row_ranges() self.assertEqual(row_ranges, [])
def test_row_range_get_range_kwargs_open_closed(): from google.cloud.bigtable.row_set import RowRange start_key = b"row_key1" end_key = b"row_key9" expected_result = {"start_key_open": start_key, "end_key_closed": end_key} row_range = RowRange(start_key, end_key, False, True) actual_result = row_range.get_range_kwargs() assert expected_result == actual_result
def test__update_message_request(self): row_set = self._make_one() table_name = 'table_name' row_set.add_row_key("row_key1") row_range1 = RowRange(b"row_key21", b"row_key29") row_set.add_row_range(row_range1) request = _ReadRowsRequestPB(table_name=table_name) row_set._update_message_request(request) expected_request = _ReadRowsRequestPB(table_name=table_name) expected_request.rows.row_keys.append(_to_bytes("row_key1")) expected_request.rows.row_ranges.add(**row_range1.get_range_kwargs()) self.assertEqual(request, expected_request)
def test__update_message_request(self): row_set = self._make_one() table_name = 'table_name' row_set.add_row_key("row_key1") row_range1 = RowRange(b"row_key21", b"row_key29") row_set.add_row_range(row_range1) request = _ReadRowsRequestPB(table_name=table_name) row_set._update_message_request(request) expected_request = _ReadRowsRequestPB(table_name=table_name) expected_request.rows.row_keys.append(_to_bytes("row_key1")) expected_request.rows.row_ranges.add(**row_range1.get_range_kwargs()) self.assertEqual(request, expected_request)
def test_row_set__update_message_request(): from google.cloud._helpers import _to_bytes from google.cloud.bigtable.row_set import RowRange from google.cloud.bigtable.row_set import RowSet row_set = RowSet() table_name = "table_name" row_set.add_row_key("row_key1") row_range1 = RowRange(b"row_key21", b"row_key29") row_set.add_row_range(row_range1) request = _ReadRowsRequestPB(table_name=table_name) row_set._update_message_request(request) expected_request = _ReadRowsRequestPB(table_name=table_name) expected_request.rows.row_keys.append(_to_bytes("row_key1")) expected_request.rows.row_ranges.append(row_range1.get_range_kwargs()) assert request == expected_request