Esempio n. 1
0
    def test_mutate_row(self):
        # Setup Expected Response
        expected_response = {}
        expected_response = bigtable_pb2.MutateRowResponse(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = bigtable_v2.BigtableClient()

        # Setup Request
        table_name = client.table_path("[PROJECT]", "[INSTANCE]", "[TABLE]")
        row_key = b"122"
        mutations = []

        response = client.mutate_row(table_name, row_key, mutations)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = bigtable_pb2.MutateRowRequest(
            table_name=table_name, row_key=row_key, mutations=mutations
        )
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Esempio n. 2
0
    def test_mutate_row(self):
        # Setup Expected Response
        expected_response = {}
        expected_response = bigtable_pb2.MutateRowResponse(**expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        client = bigtable_v2.BigtableClient(channel=channel)

        # Setup Request
        table_name = client.table_path('[PROJECT]', '[INSTANCE]', '[TABLE]')
        row_key = b'122'
        mutations = []

        response = client.mutate_row(table_name, row_key, mutations)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = bigtable_pb2.MutateRowRequest(table_name=table_name,
                                                         row_key=row_key,
                                                         mutations=mutations)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request