Exemplo n.º 1
0
    def test_to_pb(self):
        from gcloud.bigtable._generated import bigtable_data_pb2 as data_pb2

        row_filter = self._makeOne()
        expected_pb = data_pb2.RowFilter(
            value_range_filter=data_pb2.ValueRange())
        self.assertEqual(row_filter.to_pb(), expected_pb)
Exemplo n.º 2
0
    def to_pb(self):
        """Converts the row filter to a protobuf.

        First converts to a :class:`.data_pb2.ValueRange` and then uses
        it to create a row filter protobuf.

        :rtype: :class:`.data_pb2.RowFilter`
        :returns: The converted current object.
        """
        value_range_kwargs = {}
        if self.start_value is not None:
            if self.inclusive_start:
                key = 'start_value_inclusive'
            else:
                key = 'start_value_exclusive'
            value_range_kwargs[key] = _to_bytes(self.start_value)
        if self.end_value is not None:
            if self.inclusive_end:
                key = 'end_value_inclusive'
            else:
                key = 'end_value_exclusive'
            value_range_kwargs[key] = _to_bytes(self.end_value)

        value_range = data_pb2.ValueRange(**value_range_kwargs)
        return data_pb2.RowFilter(value_range_filter=value_range)
Exemplo n.º 3
0
    def test_to_pb_exclusive_end(self):
        from gcloud.bigtable._generated import bigtable_data_pb2 as data_pb2

        value = b'some-value'
        row_filter = self._makeOne(end_value=value, inclusive_end=False)
        val_range_pb = data_pb2.ValueRange(end_value_exclusive=value)
        expected_pb = data_pb2.RowFilter(value_range_filter=val_range_pb)
        self.assertEqual(row_filter.to_pb(), expected_pb)