Skip to content

Commit

Permalink
Addressing review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Feb 15, 2016
1 parent 0f974cb commit 321435e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
6 changes: 3 additions & 3 deletions gcloud/bigtable/row.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,10 @@ def _commit_check_and_mutate(self):
def clear_mutations(self):
"""Removes all currently accumulated mutations on the current row."""
if self._filter is None:
self._pb_mutations[:] = []
del self._pb_mutations[:]
else:
self._true_pb_mutations[:] = []
self._false_pb_mutations[:] = []
del self._true_pb_mutations[:]
del self._false_pb_mutations[:]

def commit(self):
"""Makes a ``MutateRow`` or ``CheckAndMutateRow`` API request.
Expand Down
22 changes: 16 additions & 6 deletions gcloud/bigtable/test_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,21 +460,30 @@ def test_commit_with_filter(self):
row = self._makeOne(row_key, table, filter_=row_filter)

# Create request_pb
value = b'bytes-value'
mutation = data_pb2.Mutation(
value1 = b'bytes-value'
mutation1 = data_pb2.Mutation(
set_cell=data_pb2.Mutation.SetCell(
family_name=column_family_id,
column_qualifier=column,
timestamp_micros=-1, # Default value.
value=value,
value=value1,
),
)
value2 = b'other-bytes'
mutation2 = data_pb2.Mutation(
set_cell=data_pb2.Mutation.SetCell(
family_name=column_family_id,
column_qualifier=column,
timestamp_micros=-1, # Default value.
value=value2,
),
)
request_pb = messages_pb2.CheckAndMutateRowRequest(
table_name=table_name,
row_key=row_key,
predicate_filter=row_filter.to_pb(),
true_mutations=[mutation],
false_mutations=[],
true_mutations=[mutation1],
false_mutations=[mutation2],
)

# Create response_pb
Expand All @@ -489,7 +498,8 @@ def test_commit_with_filter(self):
expected_result = predicate_matched

# Perform the method and check the result.
row.set_cell(column_family_id, column, value, state=True)
row.set_cell(column_family_id, column, value1, state=True)
row.set_cell(column_family_id, column, value2, state=False)
result = row.commit()
self.assertEqual(result, expected_result)
self.assertEqual(stub.method_calls, [(
Expand Down

0 comments on commit 321435e

Please sign in to comment.