Example #1
0
    def _from_pb_test_helper(self, labels=None):
        import datetime
        from google.cloud._helpers import _EPOCH
        from google.cloud.bigtable_v2.proto import data_pb2 as data_v2_pb2

        timestamp_micros = TestCell.timestamp_micros
        timestamp = _EPOCH + datetime.timedelta(microseconds=timestamp_micros)
        value = b"value-bytes"

        if labels is None:
            cell_pb = data_v2_pb2.Cell(value=value,
                                       timestamp_micros=timestamp_micros)
            cell_expected = self._make_one(value, timestamp_micros)
        else:
            cell_pb = data_v2_pb2.Cell(value=value,
                                       timestamp_micros=timestamp_micros,
                                       labels=labels)
            cell_expected = self._make_one(value,
                                           timestamp_micros,
                                           labels=labels)

        klass = self._get_target_class()
        result = klass.from_pb(cell_pb)
        self.assertEqual(result, cell_expected)
        self.assertEqual(result.timestamp, timestamp)
Example #2
0
def _CellPB(*args, **kw):
    from google.cloud.bigtable_v2.proto import (data_pb2 as data_v2_pb2)

    return data_v2_pb2.Cell(*args, **kw)