def test_check_valid_creds(self):
        # Setup Expected Response
        has_valid_creds = False
        expected_response = {"has_valid_creds": has_valid_creds}
        expected_response = datatransfer_pb2.CheckValidCredsResponse(
            **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 = bigquery_datatransfer_v1.DataTransferServiceClient()

        # Setup Request
        name = client.project_data_source_path("[PROJECT]", "[DATA_SOURCE]")

        response = client.check_valid_creds(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = datatransfer_pb2.CheckValidCredsRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Пример #2
0
    def test_check_valid_creds(self):
        # Setup Expected Response
        has_valid_creds = False
        expected_response = {'has_valid_creds': has_valid_creds}
        expected_response = datatransfer_pb2.CheckValidCredsResponse(
            **expected_response)

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

        # Setup Request
        name = client.project_data_source_path('[PROJECT]', '[DATA_SOURCE]')

        response = client.check_valid_creds(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = datatransfer_pb2.CheckValidCredsRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request