简体   繁体   English

如何使用 FastAPI 和 GremlinPython 在 JanusGraph 上对 Gremlin 查询进行单元测试

[英]How to unit test Gremlin Queries on JanusGraph using FastAPI and GremlinPython

I have written a Python REST API using FastAPI.我使用 FastAPI 编写了 Python REST API。 It connects to Janus Graph on a remote machine and runs some Gremlin Queries using the GremlinPython API.它连接到远程机器上的 Janus Graph 并使用 GremlinPython API 运行一些 Gremlin 查询。 While writing my unit tests using FastAPI's built in test client, I cannot mock Janus Graph and test my APIs.在使用 FastAPI 的内置测试客户端编写单元测试时,我无法模拟 Janus Graph 并测试我的 API。 In the worst case I need to run Janus on docker in my local setup and test there.在最坏的情况下,我需要在我的本地设置中在 docker 上运行 Janus 并在那里进行测试。 However, I would like to do a pure unit test.但是,我想做一个纯单元测试。 I've not come across any useful documentation so far.到目前为止,我还没有遇到任何有用的文档。 Can anyone please help?有人可以帮忙吗?

I think running Gremlin Server locally is how a lot of people do local testing.我认为在本地运行 Gremlin Server 是很多人进行本地测试的方式。 If you do not need to test data persistence you could configure JanusGraph to use the "inmemory" backend and avoid the need to provision any storage nodes.如果您不需要测试数据持久性,您可以将 JanusGraph 配置为使用“inmemory”后端并避免配置任何存储节点。

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

相关问题 如何在python lambda中对aws athena sql查询进行单元测试? - How to unit test aws athena sql queries in python lambda? Amazon Neptune:如何使用 tinkerpop/gremlinpython package 在 Python 中创建自定义顶点 ID? - Amazon Neptune: How to create custom vertex id in Python using tinkerpop/gremlinpython package? 如何使用sqlalchemy和sqlite测试mysql查询? - How to test mysql queries using sqlalchemy and sqlite? FastAPI:如何通过覆盖 `Depends()` 中的函数来测试 API - FastAPI: How to test APIs by overriding functions in `Depends()` 在 Python3 中使用单元测试进行单元测试 - Unit testing using unit test in Python3 如何使用 python 的 unittest mock 构建单元测试用例? - How to build unit test cases using python's unittest mock? 使用 Try 和 except 时如何对 Python 中的错误进行单元测试 - How to Unit Test errors in Python when using Try and Except 如何使用带有 Pytest 参数化副作用的补丁进行单元测试? - How to unit test using patch with a side effect with Pytest parametrize? 如何使用 pytest 在 python 中对“request.form”进行单元测试? - How to unit test “request.form” in python using pytest? 如何使用 fastapi 部署可扩展的 API? - How to deploy a scalable API using fastapi?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM