使用Python通过XRay API导入黄瓜测试结果
我正在尝试使用Python上的Xray API执行黄瓜测试的导入,更具体地说,我正在尝试在Python端翻译这个curl(它是一个多部分形式):
curl -u usr:pass -F info=@$xrayResultFilePath -F result=@$pathToCucumberJson $jiraUrl/rest/raven/1.0/import/execution/cucumber/multipart
我以多种不同的方式尝试了python代码我被困在看起来像这样的事情上:
response = requests.post(
atc_xray_url,
auth=(creds.username, creds.password),
files={"info": open("cucumber.result.json", "rb"),
"result": open("xray_result.json", "rb")},
)
response.raise_for_status()
我还尝试更改标签,将它们添加到像我在互联网上找到的元组中,在这里找到解决方案,但每次我收到此错误时都没有结果:
<status><status-code>404</status-code><message>null for uri:
卷曲正在工作,但是Python 代码不是。我可以使用 subprocess 库,但这应该是一个多平台解决方案,所以如果这可以用 Python 中的东西来完成,那就太好了。
I'm trying to perform an import of a cucumber test with the Xray API on Python, to be more specific I'm trying to translate this curl on Python side (it's a multipart form) :
curl -u usr:pass -F info=@$xrayResultFilePath -F result=@$pathToCucumberJson $jiraUrl/rest/raven/1.0/import/execution/cucumber/multipart
I tried in many different ways the python code I'm stucked on looks something like this:
response = requests.post(
atc_xray_url,
auth=(creds.username, creds.password),
files={"info": open("cucumber.result.json", "rb"),
"result": open("xray_result.json", "rb")},
)
response.raise_for_status()
I also tried to change the tags, to add them in a tuple like I found on the internet, solutions found here, but no result everytime I get this error:
<status><status-code>404</status-code><message>null for uri:
The curl is working, but the Python code is not. I could use the subprocess library but this shoud be a multiplatform solution so if this could be done with a thing in Python, it would be nice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不久前提供的 这个存储库 提供了几个代码片段,包括 < a href="https://github.com/Xray-App/xray-code-snippets/blob/main/use_cases/import_automation_results/python/import_results_cucumber_multipart.py" rel="nofollow noreferrer">one 正是针对该用例。
不过,您的代码与以下代码类似;如果您的 Jira DC 版本 >= 8.14,您可以使用基本身份验证或个人身份验证令牌。
根据您获得的结果代码,问题可能出在您使用的 URL 上,不清楚它是否与您的 curl 上的相同。请注意,您还可以使用端点的 v2,如我前面所示。
This repository that I made available some time ago provides several code snippets, including one precisely for that use case.
Your code is similar to the following one though; you may use basic auth or personal auth tokens, if you have a Jira DC version >= 8.14.
Given the result code you obtain, the problem may be on the URL that you use, which is not clear whether it's the same or not that you have on your curl. Note that you can also use v2 of the endpoint, as I show ahead.