@@ -982,7 +982,6 @@ def test_ctor(self):
982982 assert instance_key in client ._active_instances
983983 assert client ._instance_owners [instance_key ] == {id (table )}
984984 assert isinstance (table ._metrics , BigtableClientSideMetricsController )
985- assert table ._metrics .interceptor == client ._metrics_interceptor
986985 assert table .default_operation_timeout == expected_operation_timeout
987986 assert table .default_attempt_timeout == expected_attempt_timeout
988987 assert (
@@ -1251,7 +1250,6 @@ def test_ctor(self):
12511250 assert instance_key in client ._active_instances
12521251 assert client ._instance_owners [instance_key ] == {id (view )}
12531252 assert isinstance (view ._metrics , BigtableClientSideMetricsController )
1254- assert view ._metrics .interceptor == client ._metrics_interceptor
12551253 assert view .default_operation_timeout == expected_operation_timeout
12561254 assert view .default_attempt_timeout == expected_attempt_timeout
12571255 assert (
@@ -1621,9 +1619,13 @@ def test_read_row(self):
16211619 with self ._make_client () as client :
16221620 table = client .get_table ("instance" , "table" )
16231621 row_key = b"test_1"
1624- with mock .patch .object (table , "read_rows" ) as read_rows :
1622+ with mock .patch .object (
1623+ CrossSync ._Sync_Impl , "_ReadRowsOperation"
1624+ ) as mock_op_constructor :
1625+ mock_op = mock .Mock ()
16251626 expected_result = object ()
1626- read_rows .side_effect = lambda * args , ** kwargs : [expected_result ]
1627+ mock_op .start_operation .return_value = [expected_result ]
1628+ mock_op_constructor .return_value = mock_op
16271629 expected_op_timeout = 8
16281630 expected_req_timeout = 4
16291631 row = table .read_row (
@@ -1632,42 +1634,45 @@ def test_read_row(self):
16321634 attempt_timeout = expected_req_timeout ,
16331635 )
16341636 assert row == expected_result
1635- assert read_rows .call_count == 1
1636- (args , kwargs ) = read_rows .call_args_list [0 ]
1637+ assert mock_op_constructor .call_count == 1
1638+ (args , kwargs ) = mock_op_constructor .call_args_list [0 ]
16371639 assert kwargs ["operation_timeout" ] == expected_op_timeout
16381640 assert kwargs ["attempt_timeout" ] == expected_req_timeout
1639- assert len (args ) == 1
1641+ assert len (args ) == 2
16401642 assert isinstance (args [0 ], ReadRowsQuery )
16411643 query = args [0 ]
16421644 assert query .row_keys == [row_key ]
16431645 assert query .row_ranges == []
16441646 assert query .limit == 1
1647+ assert args [1 ] is table
16451648
16461649 def test_read_row_w_filter (self ):
16471650 """Test reading a single row with an added filter"""
16481651 with self ._make_client () as client :
16491652 table = client .get_table ("instance" , "table" )
16501653 row_key = b"test_1"
1651- with mock .patch .object (table , "read_rows" ) as read_rows :
1654+ with mock .patch .object (
1655+ CrossSync ._Sync_Impl , "_ReadRowsOperation"
1656+ ) as mock_op_constructor :
1657+ mock_op = mock .Mock ()
16521658 expected_result = object ()
1653- read_rows .side_effect = lambda * args , ** kwargs : [expected_result ]
1659+ mock_op .start_operation .return_value = [expected_result ]
1660+ mock_op_constructor .return_value = mock_op
16541661 expected_op_timeout = 8
16551662 expected_req_timeout = 4
1656- mock_filter = mock .Mock ()
1657- expected_filter = {"filter" : "mock filter" }
1658- mock_filter ._to_dict .return_value = expected_filter
1663+ expected_filter = mock .Mock ()
16591664 row = table .read_row (
16601665 row_key ,
16611666 operation_timeout = expected_op_timeout ,
16621667 attempt_timeout = expected_req_timeout ,
16631668 row_filter = expected_filter ,
16641669 )
16651670 assert row == expected_result
1666- assert read_rows .call_count == 1
1667- (args , kwargs ) = read_rows .call_args_list [0 ]
1671+ assert mock_op_constructor .call_count == 1
1672+ (args , kwargs ) = mock_op_constructor .call_args_list [0 ]
16681673 assert kwargs ["operation_timeout" ] == expected_op_timeout
16691674 assert kwargs ["attempt_timeout" ] == expected_req_timeout
1670- assert len (args ) == 1
1675+ assert len (args ) == 2
16711676 assert isinstance (args [0 ], ReadRowsQuery )
16721677 query = args [0 ]
16731678 assert query .row_keys == [row_key ]
@@ -1680,8 +1685,12 @@ def test_read_row_no_response(self):
16801685 with self ._make_client () as client :
16811686 table = client .get_table ("instance" , "table" )
16821687 row_key = b"test_1"
1683- with mock .patch .object (table , "read_rows" ) as read_rows :
1684- read_rows .side_effect = lambda * args , ** kwargs : []
1688+ with mock .patch .object (
1689+ CrossSync ._Sync_Impl , "_ReadRowsOperation"
1690+ ) as mock_op_constructor :
1691+ mock_op = mock .Mock ()
1692+ mock_op .start_operation .return_value = []
1693+ mock_op_constructor .return_value = mock_op
16851694 expected_op_timeout = 8
16861695 expected_req_timeout = 4
16871696 result = table .read_row (
@@ -1690,8 +1699,8 @@ def test_read_row_no_response(self):
16901699 attempt_timeout = expected_req_timeout ,
16911700 )
16921701 assert result is None
1693- assert read_rows .call_count == 1
1694- (args , kwargs ) = read_rows .call_args_list [0 ]
1702+ assert mock_op_constructor .call_count == 1
1703+ (args , kwargs ) = mock_op_constructor .call_args_list [0 ]
16951704 assert kwargs ["operation_timeout" ] == expected_op_timeout
16961705 assert kwargs ["attempt_timeout" ] == expected_req_timeout
16971706 assert isinstance (args [0 ], ReadRowsQuery )
@@ -1709,21 +1718,28 @@ def test_row_exists(self, return_value, expected_result):
17091718 with self ._make_client () as client :
17101719 table = client .get_table ("instance" , "table" )
17111720 row_key = b"test_1"
1712- with mock .patch .object (table , "read_rows" ) as read_rows :
1713- read_rows .side_effect = lambda * args , ** kwargs : return_value
1714- expected_op_timeout = 1
1715- expected_req_timeout = 2
1721+ with mock .patch .object (
1722+ CrossSync ._Sync_Impl , "_ReadRowsOperation"
1723+ ) as mock_op_constructor :
1724+ mock_op = mock .Mock ()
1725+ mock_op .start_operation .return_value = return_value
1726+ mock_op_constructor .return_value = mock_op
1727+ expected_op_timeout = 2
1728+ expected_req_timeout = 1
17161729 result = table .row_exists (
17171730 row_key ,
17181731 operation_timeout = expected_op_timeout ,
17191732 attempt_timeout = expected_req_timeout ,
17201733 )
17211734 assert expected_result == result
1722- assert read_rows .call_count == 1
1723- (args , kwargs ) = read_rows .call_args_list [0 ]
1735+ assert mock_op_constructor .call_count == 1
1736+ (args , kwargs ) = mock_op_constructor .call_args_list [0 ]
17241737 assert kwargs ["operation_timeout" ] == expected_op_timeout
17251738 assert kwargs ["attempt_timeout" ] == expected_req_timeout
1726- assert isinstance (args [0 ], ReadRowsQuery )
1739+ query = args [0 ]
1740+ assert isinstance (query , ReadRowsQuery )
1741+ assert query .row_keys == [row_key ]
1742+ assert query .limit == 1
17271743 expected_filter = {
17281744 "chain" : {
17291745 "filters" : [
@@ -1732,10 +1748,6 @@ def test_row_exists(self, return_value, expected_result):
17321748 ]
17331749 }
17341750 }
1735- query = args [0 ]
1736- assert query .row_keys == [row_key ]
1737- assert query .row_ranges == []
1738- assert query .limit == 1
17391751 assert query .filter ._to_dict () == expected_filter
17401752
17411753
0 commit comments