简体   繁体   English

使用于访问谷歌云存储的谷歌python客户端库达到了一个存根API

[英]Make the Google python client library for accessing Google cloud storage hit a stubbed API

I am writing an application that uses Google's python client for GCS. 我正在编写一个使用Google的python客户端进行GCS的应用程序。

https://cloud.google.com/storage/docs/reference/libraries#client-libraries-install-python https://cloud.google.com/storage/docs/reference/libraries#client-libraries-install-python

I've had no issues using this, until I needed to write my functional tests. 在我需要编写功能测试之前,我没有遇到任何问题。

The way our organization tests integrations like this is to write a simple stub of the API endpoints I hit, and point the Google client library (in this case) to my stub, instead of needing to hit Google's live endpoints. 我们的组织测试这样的集成的方式是编写我点击的API端点的简单存根,并将Google客户端库(在本例中)指向我的存根,而不是需要访问Google的实时端点。

I'm using a service account for authentication and am able to point the client at my stub when fetching a token because it gets that value from the service account's json key that you get when you create the service account. 我正在使用服务帐户进行身份验证,并且在获取令牌时能够将客户端指向我的存根,因为它从您在创建服务帐户时获得的服务帐户的json密钥中获取该值。

What I don't seem able to do is point the client library at my stubbed API instead of making calls directly to Google. 我似乎无法做的是将客户端库指向我的存根API,而不是直接向Google调用。

Some work arounds that I've though of, that I don't like are: - Allow the tests to hit the live endpoints. 我曾经做过的一些我不喜欢的解决办法是: - 允许测试点击实时端点。 - Put in some configuration that toggles using the real Google client library, or a mocked version of the library. - 使用真正的Google客户端库或模拟版本的库进行一些切换。 I'd rather mock the API versus having mock code deployed to production. 我宁愿模仿API而不是将模拟代码部署到生产中。

Any help with this is greatly appreciated. 非常感谢任何帮助。

I've made some research and it seems like there's nothing supported specifically for Cloud Storage using python. 我已经做了一些研究,似乎没有什么专门支持使用python的云存储。 I found this GitHub issue entry with a related discussion, but for go. 我发现这个GitHub问题条目与相关的讨论,但为了去。

I think you can open a public issue tracker asking for this functionality. 我想你可以打开一个公共问题跟踪器来询问这个功能。 I'm afraid by now it's easier to keep using your second workaround. 我现在害怕继续使用你的第二种解决方法更容易。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Python api-client-library将文本文件上传到Google Cloud Storage。 适用于图片,而非文字 - Upload text file to Google Cloud Storage with Python api-client-library. Works with image, not text 通过pip安装Google Cloud Storage客户端库-Python GAE - Install Google Cloud Storage Client Library with pip — Python GAE 如何使用 Python 客户端库修改 Google Cloud Storage object? - How to modify a Google Cloud Storage object using Python client library? 通过python访问Google云存储时出错 - Error accessing google cloud storage through python 使用Google Cloud Storage python客户端进行批量请求 - Batch request with Google Cloud Storage python client 适用于Google云端存储和大文件的Python客户端 - Python Client for Google Cloud Storage and large files 从 Google Cloud Python 作业访问 Google Storage 上的文件 - Accessing files on Google Storage from a Google Cloud Python job 使用HTTP 416从带有api客户端库的谷歌云存储下载失败 - Downloading from google cloud storage with api client library fails with HTTP 416 如何在谷歌云存储 python 库中正确使用 create_anonymous_client() 函数来访问公共存储桶? - How to properly use create_anonymous_client() function in google cloud storage python library for access on public buckets? Google Cloud Storage Python Client Library 中的 list_blobs function 中的分页是如何工作的 - How does paging work in the list_blobs function in Google Cloud Storage Python Client Library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM