Пример #1
0
    def test_list_traces_exception(self):
        channel = ChannelStub(responses=[CustomException()])
        patch = mock.patch('google.api_core.grpc_helpers.create_channel')
        with patch as create_channel:
            create_channel.return_value = channel
            client = trace_v1.TraceServiceClient()

        # Setup request
        project_id = 'projectId-1969970175'

        paged_list_response = client.list_traces(project_id)
        with pytest.raises(CustomException):
            list(paged_list_response)
    def test_patch_traces_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = trace_v1.TraceServiceClient()

        # Setup request
        project_id = "projectId-1969970175"
        traces = {}

        with pytest.raises(CustomException):
            client.patch_traces(project_id, traces)
Пример #3
0
    def test_get_trace_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        patch = mock.patch('google.api_core.grpc_helpers.create_channel')
        with patch as create_channel:
            create_channel.return_value = channel
            client = trace_v1.TraceServiceClient()

        # Setup request
        project_id = 'projectId-1969970175'
        trace_id = 'traceId1270300245'

        with pytest.raises(CustomException):
            client.get_trace(project_id, trace_id)
    def test_patch_traces(self):
        channel = ChannelStub()
        client = trace_v1.TraceServiceClient(channel=channel)

        # Setup Request
        project_id = 'projectId-1969970175'
        traces = {}

        client.patch_traces(project_id, traces)

        assert len(channel.requests) == 1
        expected_request = trace_pb2.PatchTracesRequest(project_id=project_id,
                                                        traces=traces)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_patch_traces(self):
        channel = ChannelStub()
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = trace_v1.TraceServiceClient()

        # Setup Request
        project_id = "projectId-1969970175"
        traces = {}

        client.patch_traces(project_id, traces)

        assert len(channel.requests) == 1
        expected_request = trace_pb2.PatchTracesRequest(project_id=project_id,
                                                        traces=traces)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Пример #6
0
def client():
    return trace_v1.TraceServiceClient()
Пример #7
0
    def test_list_traces(self):
        project_id = os.environ['PROJECT_ID']

        client = trace_v1.TraceServiceClient()
        project_id_2 = project_id
        response = client.list_traces(project_id_2)
Пример #8
0
def trace_id():
    # list all traces in the project and return the first
    client = trace_v1.TraceServiceClient()
    traces = client.list_traces(project_id=PROJECT_ID)

    return list(traces)[0].trace_id