• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python conftest.register_spec函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.functional.conftest.register_spec函数的典型用法代码示例。如果您正苦于以下问题:Python register_spec函数的具体用法?Python register_spec怎么用?Python register_spec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了register_spec函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_invalid_type_in_response_raises_ValidationError

def test_invalid_type_in_response_raises_ValidationError(
        httprettified, swagger_dict, sample_model):
    register_spec(swagger_dict)
    register_get("http://localhost/test_http", body='"NOT_COMPLEX_TYPE"')
    with pytest.raises(ValidationError) as excinfo:
        SwaggerClient.from_url(API_DOCS_URL).api_test.testHTTP().result()
    assert "'NOT_COMPLEX_TYPE' is not of type" in str(excinfo.value)
开发者ID:Yelp,项目名称:bravado,代码行数:7,代码来源:model_func_test.py


示例2: test_default_value_in_request

def test_default_value_in_request(httprettified, swagger_dict):
    swagger_dict['paths']['/test_http']['get']['parameters'][0]['default'] = 'X'
    register_spec(swagger_dict)
    register_get("http://localhost/test_http?")
    resource = SwaggerClient.from_url(API_DOCS_URL).api_test
    resource.testHTTP().result()
    assert ['X'] == httpretty.last_request().querystring['test_param']
开发者ID:althor880,项目名称:bravado,代码行数:7,代码来源:request_func_test.py


示例3: test_basePath_works

def test_basePath_works(httprettified, swagger_dict):
    swagger_dict["basePath"] = "/append"
    register_spec(swagger_dict)
    register_get("http://localhost/append/test_http?test_param=foo")
    resource = SwaggerClient.from_url(API_DOCS_URL).api_test
    resource.testHTTP(test_param="foo").result()
    assert ["foo"] == httpretty.last_request().querystring['test_param']
开发者ID:althor880,项目名称:bravado,代码行数:7,代码来源:spec_func_test.py


示例4: test_hostname_if_passed_overrides_origin_url

def test_hostname_if_passed_overrides_origin_url(httprettified, swagger_dict):
    register_get("http://foo/test_http?", body='')
    swagger_dict['host'] = 'foo'
    register_spec(swagger_dict)
    resource = SwaggerClient.from_url(API_DOCS_URL).api_test
    resource.testHTTP(test_param="foo").result()
    assert ["foo"] == httpretty.last_request().querystring['test_param']
开发者ID:althor880,项目名称:bravado,代码行数:7,代码来源:spec_func_test.py


示例5: test_invalid_spec_raises_SwaggerValidationError

def test_invalid_spec_raises_SwaggerValidationError(
        httprettified, swagger_dict):
    swagger_dict['paths']['/test_http']['get']['parameters'][0]['type'] = 'X'
    register_spec(swagger_dict)
    with pytest.raises(SwaggerValidationError) as excinfo:
        SwaggerClient.from_url(API_DOCS_URL)
    assert 'is not valid' in str(excinfo.value)
开发者ID:althor880,项目名称:bravado,代码行数:7,代码来源:spec_func_test.py


示例6: test_model_missing_required_property_in_response_raises_ValidationError

def test_model_missing_required_property_in_response_raises_ValidationError(
        httprettified, swagger_dict, sample_model):
    register_spec(swagger_dict)
    sample_model.pop("id")
    register_get("http://localhost/test_http", body=simplejson.dumps(sample_model))
    with pytest.raises(ValidationError) as excinfo:
        SwaggerClient.from_url(API_DOCS_URL).api_test.testHTTP().result()
    assert "'id' is a required property" in str(excinfo.value)
开发者ID:Yelp,项目名称:bravado,代码行数:8,代码来源:model_func_test.py


示例7: test_correct_route_with_basePath_no_slash

def test_correct_route_with_basePath_no_slash(httprettified, swagger_dict):
    register_get(
        "http://localhost/lame/test/test_http?test_param=foo",
        body=u'""')
    swagger_dict["basePath"] = "/lame/test"
    register_spec(swagger_dict)
    resource = SwaggerClient.from_url(API_DOCS_URL).api_test
    assert resource.testHTTP(test_param="foo").result() is None
开发者ID:althor880,项目名称:bravado,代码行数:8,代码来源:spec_func_test.py


示例8: test_additionalProperty_in_model_in_response

def test_additionalProperty_in_model_in_response(
        httprettified, swagger_dict, sample_model):
    register_spec(swagger_dict)
    sample_model["extra"] = 42
    register_get("http://localhost/test_http", body=simplejson.dumps(sample_model))
    resource = SwaggerClient.from_url(API_DOCS_URL).api_test
    result = resource.testHTTP().result()
    assert result.extra == 42
开发者ID:Yelp,项目名称:bravado,代码行数:8,代码来源:model_func_test.py


示例9: test_error_on_wrong_type_inside_complex_type

def test_error_on_wrong_type_inside_complex_type(
        httprettified, swagger_dict, sample_model):
    register_spec(swagger_dict)
    sample_model["id"] = "Not Integer"
    register_get("http://localhost/test_http", body=simplejson.dumps(sample_model))
    with pytest.raises(ValidationError) as excinfo:
        SwaggerClient.from_url(API_DOCS_URL).api_test.testHTTP().result()
    assert "'Not Integer' is not of type" in str(excinfo.value)
开发者ID:Yelp,项目名称:bravado,代码行数:8,代码来源:model_func_test.py


示例10: test_error_on_missing_type_in_model

def test_error_on_missing_type_in_model(
        httprettified, swagger_dict, sample_model):
    register_spec(swagger_dict)
    sample_model["schools"][0] = {}  # Omit 'name'
    register_get("http://localhost/test_http", body=simplejson.dumps(sample_model))
    with pytest.raises(ValidationError) as excinfo:
        SwaggerClient.from_url(API_DOCS_URL).api_test.testHTTP().result()
    assert "'name' is a required property" in str(excinfo.value)
开发者ID:Yelp,项目名称:bravado,代码行数:8,代码来源:model_func_test.py


示例11: test_default_value_not_in_request

def test_default_value_not_in_request(httprettified, swagger_dict):
    # Default should be applied on the server side so no need to send it in
    # the request.
    swagger_dict['paths']['/test_http']['get']['parameters'][0]['default'] = 'X'
    register_spec(swagger_dict)
    register_get("http://localhost/test_http?")
    resource = SwaggerClient.from_url(API_DOCS_URL).api_test
    resource.testHTTP().result()
    assert 'test_param' not in httpretty.last_request().querystring
开发者ID:analogue,项目名称:bravado,代码行数:9,代码来源:request_func_test.py


示例12: test_primitive_types_returned_in_response

def test_primitive_types_returned_in_response(httprettified, swagger_dict):
    rtypes = {
        'string': '"test"',
        'integer': 42,
        'number': 3.4,
        'boolean': True
    }
    for rtype, rvalue in rtypes.iteritems():
        register_spec(swagger_dict, {'type': rtype})
        register_test_http(body=json.dumps(rvalue))
        assert_result(rvalue)
开发者ID:bpicolo,项目名称:bravado,代码行数:11,代码来源:response_func_test.py


示例13: test_array_in_response

def test_array_in_response(httprettified, swagger_dict):
    response_spec = {
        'type': 'array',
        'items': {
            'type': 'string',
        },
    }
    register_spec(swagger_dict, response_spec)
    expected_array = ['inky', 'dinky', 'doo']
    register_test_http(body=json.dumps(expected_array))
    assert_result(expected_array)
开发者ID:bpicolo,项目名称:bravado,代码行数:11,代码来源:response_func_test.py


示例14: test_invalid_primitive_types_in_response_raises_ValidationError

def test_invalid_primitive_types_in_response_raises_ValidationError(
        httprettified, swagger_dict):
    rtypes = {
        'string': 42,
        'integer': 3.4,
        'number': 'foo',
        'boolean': '"NOT_BOOL"'
    }
    for rtype, rvalue in rtypes.iteritems():
        register_spec(swagger_dict, {'type': rtype})
        register_test_http(body=json.dumps(rvalue))
        assert_raises_and_matches(ValidationError, 'is not of type')
开发者ID:bpicolo,项目名称:bravado,代码行数:12,代码来源:response_func_test.py


示例15: test_parameter_in_path_of_request

def test_parameter_in_path_of_request(httprettified, swagger_dict):
    path_param_spec = {
        "in": "path",
        "name": "param_id",
        "type": "string"
    }
    paths_spec = swagger_dict['paths']
    paths_spec['/test_http/{param_id}'] = paths_spec.pop('/test_http')
    paths_spec['/test_http/{param_id}']['get']['parameters'].append(
        path_param_spec)
    register_spec(swagger_dict)
    register_get('http://localhost/test_http/42?test_param=foo')
    resource = SwaggerClient.from_url(API_DOCS_URL).api_test
    assert resource.testHTTP(test_param="foo", param_id="42").result() is None
开发者ID:analogue,项目名称:bravado,代码行数:14,代码来源:request_func_test.py


示例16: test_parameter_in_path_of_request

def test_parameter_in_path_of_request(httprettified, swagger_dict):
    path_param_spec = {
        'in': 'path',
        'name': 'param_id',
        'required': True,
        'type': 'string',
    }
    paths_spec = swagger_dict['paths']
    paths_spec['/test_http/{param_id}'] = paths_spec.pop('/test_http')
    paths_spec['/test_http/{param_id}']['get']['parameters'].append(
        path_param_spec)
    register_spec(swagger_dict)
    register_get('http://localhost/test_http/42?test_param=foo')
    resource = SwaggerClient.from_url(API_DOCS_URL).api_test
    assert resource.testHTTP(test_param='foo', param_id='42').result() is None
开发者ID:Yelp,项目名称:bravado,代码行数:15,代码来源:request_func_test.py


示例17: test_model_in_response

def test_model_in_response(httprettified, swagger_dict, sample_model):
    register_spec(swagger_dict)
    register_get("http://localhost/test_http", body=json.dumps(sample_model))
    client = SwaggerClient.from_url(API_DOCS_URL)
    result = client.api_test.testHTTP().result()
    User = client.get_model('User')
    School = client.get_model('School')
    assert isinstance(result, User)
    for school in result.schools:
        assert isinstance(school, School)
    assert User(
        id=42,
        schools=[
            School(name="School1"),
            School(name="School2")
        ]) == result
开发者ID:ealter,项目名称:bravado,代码行数:16,代码来源:model_func_test.py


示例18: test_model_in_body_of_request

def test_model_in_body_of_request(httprettified, swagger_dict, sample_model):
    param_spec = {
        "in": "body",
        "name": "body",
        "schema": {
            "$ref": "#/definitions/User"
        }
    }
    swagger_dict["paths"]["/test_http"]['post']["parameters"] = [param_spec]
    register_spec(swagger_dict)
    httpretty.register_uri(httpretty.POST, "http://localhost/test_http")
    client = SwaggerClient.from_url(API_DOCS_URL)
    resource = client.api_test
    User = client.get_model('User')
    School = client.get_model('School')
    user = User(id=42, schools=[School(name='s1')])
    resource.testHTTPPost(body=user).result()
    body = simplejson.loads(httpretty.last_request().body.decode('utf-8'))
    assert {'schools': [{'name': 's1'}], 'id': 42} == body
开发者ID:Yelp,项目名称:bravado,代码行数:19,代码来源:model_func_test.py


示例19: test_array_with_collection_format_in_path_of_request

def test_array_with_collection_format_in_path_of_request(
        httprettified, swagger_dict):
    path_param_spec = {
        'in': 'path',
        'name': 'param_ids',
        'type': 'array',
        'items': {
            'type': 'integer'
        },
        'collectionFormat': 'csv',
    }
    swagger_dict['paths']['/test_http/{param_ids}'] = \
        swagger_dict['paths'].pop('/test_http')
    swagger_dict['paths']['/test_http/{param_ids}']['get']['parameters'] = \
        [path_param_spec]
    register_spec(swagger_dict)
    register_get('http://localhost/test_http/40,41,42')
    resource = SwaggerClient.from_url(API_DOCS_URL).api_test
    assert resource.testHTTP(param_ids=[40, 41, 42]).result() is None
开发者ID:analogue,项目名称:bravado,代码行数:19,代码来源:request_func_test.py


示例20: test_form_params_in_request

def test_form_params_in_request(httprettified, swagger_dict):
    param1_spec = {
        "in": "formData",
        "name": "param_id",
        "type": "integer"
    }
    param2_spec = {
        "in": "formData",
        "name": "param_name",
        "type": "string"
    }
    path_spec = swagger_dict['paths']['/test_http']
    path_spec['post'] = path_spec.pop('get')
    path_spec['post']['parameters'] = [param1_spec, param2_spec]
    register_spec(swagger_dict)
    httpretty.register_uri(httpretty.POST, "http://localhost/test_http?")
    resource = SwaggerClient.from_url(API_DOCS_URL).api_test
    resource.testHTTP(param_id=42, param_name='foo').result()
    content_type = httpretty.last_request().headers['content-type']
    assert 'application/x-www-form-urlencoded' == content_type
    body = urlparse.parse_qs(httpretty.last_request().body)
    assert {b'param_name': [b'foo'], b'param_id': [b'42']} == body
开发者ID:analogue,项目名称:bravado,代码行数:22,代码来源:request_func_test.py



注:本文中的tests.functional.conftest.register_spec函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python patch.object函数代码示例发布时间:2022-05-27
下一篇:
Python actions.simple_add_course函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap