コード例 #1
0
    def test_inspect_content(self):
        # Setup Expected Response
        expected_response = {}
        expected_response = dlp_pb2.InspectContentResponse(**expected_response)

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

        # Setup Request
        parent = client.project_path('[PROJECT]')

        response = client.inspect_content(parent)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = dlp_pb2.InspectContentRequest(parent=parent)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
コード例 #2
0
    def test_inspect_content(self):
        # Setup Expected Response
        expected_response = {}
        expected_response = dlp_pb2.InspectContentResponse(**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 = dlp_v2.DlpServiceClient()

        # Setup Request
        parent = client.project_path('[PROJECT]')

        response = client.inspect_content(parent)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = dlp_pb2.InspectContentRequest(parent=parent)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request