Skip to content

Commit

Permalink
Add getters for Bigtable Row.row_key and Row.table (#3408)
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousDima authored and dhermes committed May 12, 2017
1 parent ae98aca commit ecd4da4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions bigtable/google/cloud/bigtable/row.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ def __init__(self, row_key, table):
self._row_key = _to_bytes(row_key)
self._table = table

@property
def row_key(self):
"""Row key.
:rtype: bytes
:returns: The key for the current row.
"""
return self._row_key

@property
def table(self):
"""Row table.
:rtype: table: :class:`Table <google.cloud.bigtable.table.Table>`
:returns: table: The table that owns the row.
"""
return self._table


class _SetDeleteRow(Row):
"""Row helper for setting or deleting cell values.
Expand Down
19 changes: 19 additions & 0 deletions bigtable/tests/unit/test_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@
import unittest


class TestRow(unittest.TestCase):

@staticmethod
def _get_target_class():
from google.cloud.bigtable.row import Row
return Row

def _make_one(self, *args, **kwargs):
return self._get_target_class()(*args, **kwargs)

def test_row_key_getter(self):
row = self._make_one(row_key=b'row_key', table='table')
self.assertEqual(b'row_key', row.row_key)

def test_row_table_getter(self):
row = self._make_one(row_key=b'row_key', table='table')
self.assertEqual('table', row.table)


class Test_SetDeleteRow(unittest.TestCase):

@staticmethod
Expand Down

0 comments on commit ecd4da4

Please sign in to comment.