Skip to content

Commit 20a4838

Browse files
fix: add unit tests for supporting single-row transactions
1 parent c164573 commit 20a4838

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

bigtable/google/cloud/bigtable/row.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ def commit(self):
912912
table_name=self._table.name,
913913
row_key=self._row_key,
914914
rules=self._rule_pb_list,
915-
app_profile_id=self._table._app_profile_id
915+
app_profile_id=self._table._app_profile_id,
916916
)
917917

918918
# Reset modifications after commit-ing request.

bigtable/tests/unit/test_row.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ def test_commit(self):
409409
project_id = "project-id"
410410
row_key = b"row_key"
411411
table_name = "projects/more-stuff"
412+
app_profile_id = "app_profile_id"
412413
column_family_id1 = u"column_family_id1"
413414
column_family_id2 = u"column_family_id2"
414415
column_family_id3 = u"column_family_id3"
@@ -420,7 +421,7 @@ def test_commit(self):
420421
client = self._make_client(
421422
project=project_id, credentials=credentials, admin=True
422423
)
423-
table = _Table(table_name, client=client)
424+
table = _Table(table_name, client=client, app_profile_id=app_profile_id)
424425
row_filter = RowSampleFilter(0.33)
425426
row = self._make_one(row_key, table, filter_=row_filter)
426427

@@ -444,6 +445,8 @@ def test_commit(self):
444445
row.delete_cell(column_family_id2, column2, state=True)
445446
row.delete_cells(column_family_id3, row.ALL_COLUMNS, state=True)
446447
result = row.commit()
448+
call_args = api.transport.check_and_mutate_row.call_args.args[0]
449+
self.assertEqual(app_profile_id, call_args.app_profile_id)
447450
self.assertEqual(result, expected_result)
448451
self.assertEqual(row._true_pb_mutations, [])
449452
self.assertEqual(row._false_pb_mutations, [])
@@ -564,6 +567,7 @@ def test_commit(self):
564567
project_id = "project-id"
565568
row_key = b"row_key"
566569
table_name = "projects/more-stuff"
570+
app_profile_id = "app_profile_id"
567571
column_family_id = u"column_family_id"
568572
column = b"column"
569573

@@ -572,7 +576,7 @@ def test_commit(self):
572576
client = self._make_client(
573577
project=project_id, credentials=credentials, admin=True
574578
)
575-
table = _Table(table_name, client=client)
579+
table = _Table(table_name, client=client, app_profile_id=app_profile_id)
576580
row = self._make_one(row_key, table)
577581

578582
# Create request_pb
@@ -593,7 +597,8 @@ def mock_parse_rmw_row_response(row_response):
593597
with _Monkey(MUT, _parse_rmw_row_response=mock_parse_rmw_row_response):
594598
row.append_cell_value(column_family_id, column, value)
595599
result = row.commit()
596-
600+
call_args = api.transport.read_modify_write_row.call_args.args[0]
601+
self.assertEqual(app_profile_id, call_args.app_profile_id)
597602
self.assertEqual(result, expected_result)
598603
self.assertEqual(row._rule_pb_list, [])
599604

@@ -819,9 +824,10 @@ def __init__(self, client=None):
819824

820825

821826
class _Table(object):
822-
def __init__(self, name, client=None):
827+
def __init__(self, name, client=None, app_profile_id=None):
823828
self.name = name
824829
self._instance = _Instance(client)
830+
self._app_profile_id = app_profile_id
825831
self.client = client
826832
self.mutated_rows = []
827833

0 commit comments

Comments
 (0)