Skip to content

Commit

Permalink
Add unit test for cell_value method on PartialRowData
Browse files Browse the repository at this point in the history
  • Loading branch information
zakons committed Dec 12, 2017
1 parent f1eea02 commit cbaf2b6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bigtable/google/cloud/bigtable/row_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def row_key(self):
"""
return self._row_key

def cell_value(self, column_family_id, column_id, index=0):
def cell_value(self, column_family_id, column, index=0):
"""Get a cell value
:type column_family_id: str
Expand All @@ -187,7 +187,7 @@ def cell_value(self, column_family_id, column_id, index=0):
:rtype: bytes or :class:`int`
:returns: the cell value
"""
return self._cells[column_family_id][column_id][index].value
return self._cells[column_family_id][column][index].value


class InvalidReadRowsResponse(RuntimeError):
Expand Down
21 changes: 21 additions & 0 deletions bigtable/tests/unit/test_row_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,27 @@ def test_to_dict(self):
}
self.assertEqual(result, expected_result)

def test_cell_value(self):
from google.cloud.bigtable.row_data import Cell

family_name = u'name1'
qual = b'col1'

timestamp = object()
value = b'value-bytes'
cell = Cell(value, timestamp)

partial_row_data = self._make_one(None)
partial_row_data._cells = {
family_name: {
qual: [cell]
}
}

result = partial_row_data.cell_value(family_name, qual)
expected_result = value
self.assertEqual(result, expected_result)

def test_cells_property(self):
partial_row_data = self._make_one(None)
cells = {1: 2}
Expand Down

0 comments on commit cbaf2b6

Please sign in to comment.