本文整理汇总了Python中wooper.expect.expect_json_contains函数的典型用法代码示例。如果您正苦于以下问题:Python expect_json_contains函数的具体用法?Python expect_json_contains怎么用?Python expect_json_contains使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了expect_json_contains函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_object_in_array_fail
def test_object_in_array_fail(self):
with self.assertRaises(WooperAssertionError):
expect.expect_json_contains(
response,
{"baz": "spa", "second": "item"},
path="list"
)
示例2: test_item_fail
def test_item_fail(self):
with self.assertRaises(WooperAssertionError):
expect.expect_json_contains(
response,
"span",
path="list/[0]/baz"
)
示例3: test_item_in_array_fail
def test_item_in_array_fail(self):
with self.assertRaises(WooperAssertionError):
expect.expect_json_contains(
response,
2,
path="list"
)
示例4: step_impl_then_get_facets
def step_impl_then_get_facets(context, keys):
assert_200(context.response)
expect_json_contains(context.response, '_facets')
data = get_json_data(context.response)
facets = data['_facets']
for key in keys.split(','):
assert_in(key, facets)
示例5: step_impl_then_get_etag
def step_impl_then_get_etag(context, url):
if context.app.config['IF_MATCH']:
assert_200(context.response)
expect_json_contains(context.response, '_etag')
etag = get_json_data(context.response).get('_etag')
response = context.client.get(url, headers=context.headers)
expect_json_contains(response, {'_etag': etag})
示例6: step_impl_then_get_aggs
def step_impl_then_get_aggs(context, keys):
assert_200(context.response)
expect_json_contains(context.response, '_aggregations')
data = get_json_data(context.response)
aggs = data['_aggregations']
for key in keys.split(','):
assert_in(key, aggs)
示例7: step_impl_then_get_rendition_with_mimetype
def step_impl_then_get_rendition_with_mimetype(context, name, mimetype):
expect_json_contains(context.response, 'renditions')
renditions = apply_path(parse_json_response(context.response), 'renditions')
assert isinstance(renditions, dict), 'expected dict for image renditions'
desc = renditions[name]
assert isinstance(desc, dict), 'expected dict for rendition description'
assert 'href' in desc, 'expected href in rendition description'
we_can_fetch_a_file(context, desc['href'], mimetype)
示例8: step_impl_then_get_archive_ingest_result
def step_impl_then_get_archive_ingest_result(context):
assert_200(context.response)
expect_json_contains(context.response, 'task_id')
item = json.loads(context.response.get_data())
url = '/archive_ingest/%s' % (item['task_id'])
context.response = context.client.get(url, headers=context.headers)
assert_200(context.response)
test_json(context)
示例9: test_object_in_object_pass
def test_object_in_object_pass(self):
expect.expect_json_contains(
response,
{
"list":
[{"baz": "spam", "second": "item"}, 1, "qwe", ["a", "b"]]
}
)
示例10: test_object_in_object_fail
def test_object_in_object_fail(self):
with self.assertRaises(WooperAssertionError):
expect.expect_json_contains(
response,
{
"list":
[{"baz": "spa", "second": "item"}, 1, "qwe", ["a", "b"]]
}
)
示例11: step_impl_then_get_renditions
def step_impl_then_get_renditions(context, type):
expect_json_contains(context.response, 'renditions')
renditions = apply_path(parse_json_response(context.response), 'renditions')
assert isinstance(renditions, dict), 'expected dict for image renditions'
for rend_name in context.app.config['RENDITIONS'][type]:
desc = renditions[rend_name]
assert isinstance(desc, dict), 'expected dict for rendition description'
assert 'href' in desc, 'expected href in rendition description'
assert 'media' in desc, 'expected media identifier in rendition description'
we_can_fetch_a_file(context, desc['href'], 'image/jpeg')
示例12: test_fulljson_pass
def test_fulljson_pass(self):
expect.expect_json_contains(
response,
"""{
"foo": "bar",
"list": [
{"baz": "spam", "second": "item"},
1,
"qwe",
["a", "b"]
]
}"""
)
示例13: test_fulljson_fail
def test_fulljson_fail(self):
with self.assertRaises(WooperAssertionError):
expect.expect_json_contains(
response,
"""{
"foo": "bar",
"list": [
{"baz": "spam", "other": "item"},
1,
"qwe",
["a", "b"]
]
}"""
)
示例14: step_impl_then_get_file
def step_impl_then_get_file(context):
assert_200(context.response)
expect_json_contains(context.response, 'renditions')
data = get_json_data(context.response)
url = '/upload/%s' % data['_id']
headers = [('Accept', 'application/json')]
headers = unique_headers(headers, context.headers)
response = context.client.get(url, headers=headers)
assert_200(response)
assert len(response.get_data()), response
assert response.mimetype == 'application/json', response.mimetype
expect_json_contains(response, 'renditions')
expect_json_contains(response, {'mime_type': 'image/jpeg'})
fetched_data = get_json_data(context.response)
context.fetched_data = fetched_data
示例15: step_impl_then_get_field_value
def step_impl_then_get_field_value(context, field, value):
assert_200(context.response)
expect_json_contains(context.response, {field: value})