我在酒馆有个考试
test_name: Add products for tests
stages:
- name: Add product one
request:
url: http://localhost:5566/product
json:
title: Product One
description: Product One in our catalog
picture: images/product.jpeg
categories:
- title: tshirt
- title: casual
price:
currency: EUR
units: 59
method: POST
headers:
content-type: application/json
response:
status_code: 200
headers:
content-type: application/json
save:
json:
product_id: uuid
delay_after: 1
- name: Get product one
request:
url: http://localhost:5566/product/{product_id}
method: GET
headers:
content-type: application/json
response:
status_code: 200
json:
picture: images/product.jpeg
title: Product One
headers:
content-type: application/json第一阶段是将产品添加到数据库中的帖子,第二阶段是带有uuid的GET,uuid作为变量从第一阶段开始。
我想检查第二阶段的反应,只有两个具体的参数。产品的图片和标题
但是我得到了以下错误
ERROR tavern.response.base:base.py:41 Structure of returned data was different than expected - Extra keys in response: {'uuid', 'id', 'price_id', 'description'} (expected = '{'picture': 'images/product.jpeg', 'title': 'Product One'}' (type = <class 'dict'>), actual = '{'id': '1', 'uuid': '62c8c26d-c2c8-42a2-9111-2fd3186b08de', 'title': 'Product One', 'description': 'Product One in our catalog', 'picture': 'images/product.jpeg', 'price_id': '1'}' (type = <class 'dict'>))可以只定义一组参数,还是必须使用整个JSON结构?
提前感谢
发布于 2022-10-03 12:03:42
默认情况下,标头被设置为严格: False,而JSON重新设置为严格: True。
它们可以在全局范围内禁用,只需一个开关(--酒馆--严格的json: or :on),或者在test.yaml中。举例说明。
---
test_name: Check github API
stages:
- name: Make sure the JSON contains location
request:
url: https://api.github.com/users/6wl
method: GET
response:
strict: False
status_code: 200
json:
location: Manchester只有当JSON重新定位不等于曼彻斯特时,才会失败。
https://buildmedia.readthedocs.org/media/pdf/tavern/stable/tavern.pdf
第16页ish
https://stackoverflow.com/questions/71085248
复制相似问题