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

Python client.SwaggerClient类代码示例

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

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



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

示例1: test_alllow_null_as_response_if_allow_null_is_given

 def test_alllow_null_as_response_if_allow_null_is_given(self):
     self.register_urls()
     httpretty.register_uri(
         httpretty.GET, "http://localhost/test_http",
         body=json.dumps(None))
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     resource.testHTTP().result(allow_null=True)
开发者ID:bkbarry,项目名称:swagger-py,代码行数:7,代码来源:resource_model_test.py


示例2: test_success_on_post_with_path_query_and_body_params

 def test_success_on_post_with_path_query_and_body_params(self):
     query_parameter = self.parameter
     path_parameter = {
         "paramType": "path",
         "name": "param_id",
         "type": "string"
     }
     body_parameter = {
         "paramType": "body",
         "name": "body",
         "type": "string"
     }
     self.response["apis"][0]["path"] = "/params/{param_id}/test_http"
     operations = self.response["apis"][0]["operations"]
     operations[0]["method"] = "POST"
     operations[0]["parameters"] = [query_parameter,
                                    path_parameter,
                                    body_parameter]
     self.register_urls()
     httpretty.register_uri(
         httpretty.POST,
         "http://localhost/params/42/test_http?test_param=foo", body='')
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     resp = resource.testHTTP(test_param="foo", param_id="42",
                              body="some_test").result()
     self.assertEqual('some_test', httpretty.last_request().body)
     self.assertEqual(None, resp)
开发者ID:kfreedland,项目名称:swagger-py,代码行数:27,代码来源:resource_operation_test.py


示例3: test_error_if_response_is_null_and_allow_null_not_given

 def test_error_if_response_is_null_and_allow_null_not_given(self):
     self.register_urls()
     httpretty.register_uri(
         httpretty.GET, "http://localhost/test_http",
         body=json.dumps(None))
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     self.assertRaises(TypeError, resource.testHTTP().result)
开发者ID:bkbarry,项目名称:swagger-py,代码行数:7,代码来源:resource_model_test.py


示例4: test_success_on_post_with_form_params_with_files

 def test_success_on_post_with_form_params_with_files(self):
     form_parameter_1 = {
         "paramType": "form",
         "name": "param_id",
         "type": "integer"
     }
     form_parameter_2 = {
         "paramType": "form",
         "name": "file_name",
         "type": "File"
     }
     self.response["apis"][0]["operations"][0]["method"] = "POST"
     self.response["apis"][0]["operations"][0]["parameters"] = [
         form_parameter_1, form_parameter_2]
     self.register_urls()
     httpretty.register_uri(
         httpretty.POST, "http://localhost/test_http?", body='')
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     with open("test-data/1.2/simple/simple.json", "rb") as f:
         resource.testHTTP(param_id=42, file_name=f).result()
         content_type = httpretty.last_request().headers['content-type']
         self.assertTrue(content_type.startswith('multipart/form-data'))
         self.assertTrue("42" in httpretty.last_request().body)
         # instead of asserting the contents, just assert filename is there
         self.assertTrue("simple.json" in httpretty.last_request().body)
开发者ID:kfreedland,项目名称:swagger-py,代码行数:25,代码来源:resource_operation_test.py


示例5: test_none_value_response_if_response_not_OK

 def test_none_value_response_if_response_not_OK(self):
     self.register_urls()
     httpretty.register_uri(
         httpretty.GET, "http://localhost/test_http?test_param=foo",
         status=500)
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     self.assertRaises(HTTPError,
                       resource.testHTTP(test_param="foo").result)
开发者ID:kfreedland,项目名称:swagger-py,代码行数:8,代码来源:resource_response_test.py


示例6: test_correct_route_with_basePath_as_slash

 def test_correct_route_with_basePath_as_slash(self):
     httpretty.register_uri(
         httpretty.GET, "http://localhost/test_http?query=foo",
         body='[]')
     self.register_urls()
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     resp = resource.testHTTP(test_param="foo").result()
     self.assertEqual([], resp)
开发者ID:asgillmor,项目名称:swagger-py,代码行数:8,代码来源:resource_test.py


示例7: test_success_on_returning_anything_for_type_void

 def test_success_on_returning_anything_for_type_void(self):
     # default operation type is void
     self.register_urls()
     httpretty.register_uri(
         httpretty.GET, "http://localhost/test_http?test_param=foo",
         body='{"some_foo": "bar"}')
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     resp = resource.testHTTP(test_param="foo").result()
     self.assertEqual({"some_foo": "bar"}, resp)
开发者ID:kfreedland,项目名称:swagger-py,代码行数:9,代码来源:resource_response_test.py


示例8: test_success_on_passing_default_value_if_param_not_passed

 def test_success_on_passing_default_value_if_param_not_passed(self):
     self.parameter['defaultValue'] = 'testString'
     self.register_urls()
     httpretty.register_uri(httpretty.GET,
                            "http://localhost/test_http?", body='')
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     resource.testHTTP().result()
     self.assertEqual(['testString'],
                      httpretty.last_request().querystring['test_param'])
开发者ID:kfreedland,项目名称:swagger-py,代码行数:9,代码来源:resource_operation_test.py


示例9: test_alllow_null_in_response_body_if_allow_null_is_given

 def test_alllow_null_in_response_body_if_allow_null_is_given(self):
     self.register_urls()
     self.sample_model["schools"].append(None)
     httpretty.register_uri(
         httpretty.GET, "http://localhost/test_http",
         body=json.dumps(self.sample_model))
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     resp = resource.testHTTP().result(allow_null=True)
     self.assertTrue(isinstance(resp, resource.models.User))
开发者ID:bkbarry,项目名称:swagger-py,代码行数:9,代码来源:resource_model_test.py


示例10: test_success_on_date_type

 def test_success_on_date_type(self):
     self.response["apis"][0]["operations"][0]["type"] = "string"
     self.response["apis"][0]["operations"][0]["format"] = "date"
     self.register_urls()
     httpretty.register_uri(
         httpretty.GET, "http://localhost/test_http?test_param=foo",
         body='"2014-06-10"')
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     resp = resource.testHTTP(test_param="foo").result()
     self.assertEqual(resp, datetime.date(2014, 6, 10))
开发者ID:bkbarry,项目名称:swagger-py,代码行数:10,代码来源:resource_response_test.py


示例11: test_append_base_path_if_base_path_isnt_absolute

 def test_append_base_path_if_base_path_isnt_absolute(self):
     self.response["basePath"] = "/append"
     httpretty.register_uri(
         httpretty.GET, "http://localhost/append/test_http?",
         body='[]')
     self.register_urls()
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     resource.testHTTP(test_param="foo").result()
     self.assertEqual(["foo"],
                      httpretty.last_request().querystring['test_param'])
开发者ID:asgillmor,项目名称:swagger-py,代码行数:10,代码来源:resource_test.py


示例12: test_error_on_incorrect_array_type_returned

 def test_error_on_incorrect_array_type_returned(self):
     self.response["apis"][0]["operations"][0]["type"] = "array"
     self.response["apis"][0]["operations"][0]["items"] = {"type": "string"}
     self.register_urls()
     httpretty.register_uri(
         httpretty.GET, "http://localhost/test_http?test_param=foo",
         body="123.32")
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     future = resource.testHTTP(test_param="foo")
     self.assertRaises(TypeError, future)
开发者ID:kfreedland,项目名称:swagger-py,代码行数:10,代码来源:resource_response_test.py


示例13: test_api_base_path_if_passed_is_always_used_as_base_path

 def test_api_base_path_if_passed_is_always_used_as_base_path(self):
     httpretty.register_uri(
         httpretty.GET, "http://foo/test_http?", body='')
     self.response["basePath"] = "http://localhost"
     self.register_urls()
     resource = SwaggerClient(u'http://localhost/api-docs',
                              api_base_path='http://foo').api_test
     resource.testHTTP(test_param="foo").result()
     self.assertEqual(["foo"],
                      httpretty.last_request().querystring['test_param'])
开发者ID:asgillmor,项目名称:swagger-py,代码行数:10,代码来源:resource_test.py


示例14: test_success_on_returning_raw_response_if_given_in_parameter

 def test_success_on_returning_raw_response_if_given_in_parameter(self):
     self.response["apis"][0]["operations"][0]["type"] = "array"
     self.response["apis"][0]["operations"][0]["items"] = {
         "type": "string"}
     self.register_urls()
     httpretty.register_uri(
         httpretty.GET, "http://localhost/test_http?",
         body='{"some_foo": "bar"}')
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     resp = resource.testHTTP(test_param="foo").result(raw_response=True)
     self.assertEqual({"some_foo": "bar"}, resp)
开发者ID:kfreedland,项目名称:swagger-py,代码行数:11,代码来源:resource_response_test.py


示例15: test_success_on_complex_operation_response_type

 def test_success_on_complex_operation_response_type(self):
     self.register_urls()
     httpretty.register_uri(
         httpretty.GET, "http://localhost/test_http",
         body=json.dumps(self.sample_model))
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     resp = resource.testHTTP().result()
     User = resource.models.User
     School = resource.models.School
     self.assertTrue(isinstance(resp, User))
     [self.assertTrue(isinstance(x, School)) for x in resp.schools]
     self.assertEqual(User(id=42, schools=[School(
         name="School1"), School(name="School2")]), resp)
开发者ID:bkbarry,项目名称:swagger-py,代码行数:13,代码来源:resource_model_test.py


示例16: test_success_on_correct_array_type_returned_by_operation

 def test_success_on_correct_array_type_returned_by_operation(self):
     self.response["apis"][0]["operations"][0]["type"] = "array"
     self.response["apis"][0]["operations"][0]["items"] = {
         "type": "string",
         "format": "date-time"
     }
     self.register_urls()
     httpretty.register_uri(
         httpretty.GET, "http://localhost/test_http?test_param=foo",
         body='["2014-06-10T23:49:54.728+0000"]')
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     resp = resource.testHTTP(test_param="foo").result()
     self.assertEqual(resp, [datetime(
         2014, 6, 10, 23, 49, 54, 728000, tzinfo=tzutc())])
开发者ID:kfreedland,项目名称:swagger-py,代码行数:14,代码来源:resource_response_test.py


示例17: test_error_on_incorrect_primitive_types_returned

 def test_error_on_incorrect_primitive_types_returned(self):
     types = {
         'string': '42',
         'integer': '3.4',
         'number': '42',
         'boolean': '"NOT_BOOL"'
     }
     for type_ in types:
         self.response["apis"][0]["operations"][0]["type"] = type_
         self.register_urls()
         httpretty.register_uri(
             httpretty.GET, "http://localhost/test_http?test_param=foo",
             body=types[type_])
         resource = SwaggerClient(u'http://localhost/api-docs').api_test
         future = resource.testHTTP(test_param="foo")
         self.assertRaises(TypeError, future)
开发者ID:kfreedland,项目名称:swagger-py,代码行数:16,代码来源:resource_response_test.py


示例18: test_removal_of_none_attributes_from_param_body_model

 def test_removal_of_none_attributes_from_param_body_model(self):
     query_parameter = {
         "paramType": "body",
         "name": "body",
         "type": "User",
     }
     self.response["apis"][0]["operations"][0]["parameters"] = [
         query_parameter]
     self.response["models"]["User"]["properties"]["school"] = {
         "$ref": "School"}
     self.register_urls()
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     user = resource.models.User(id=42)
     future = resource.testHTTP(body=user)
     # Removed the 'school': None - key, value pair from dict
     self.assertEqual(json.dumps({'id': 42, 'schools': []}),
                      future._http_client.request_params['data'])
开发者ID:bkbarry,项目名称:swagger-py,代码行数:17,代码来源:resource_model_test.py


示例19: test_success_model_in_param_body_converts_to_dict

 def test_success_model_in_param_body_converts_to_dict(self):
     query_parameter = {
         "paramType": "body",
         "name": "body",
         "type": "User",
     }
     self.response["apis"][0]["operations"][0]["parameters"] = [
         query_parameter]
     self.register_urls()
     resource = SwaggerClient(u'http://localhost/api-docs').api_test
     School = resource.models.School
     # Also test all None items are removed from array list
     user = resource.models.User(id=42, schools=[School(name='s1'), None])
     future = resource.testHTTP(body=user)
     self.assertEqual(json.dumps({'id': 42,
                                  'schools': [{'name': 's1'}]}),
                      future._http_client.request_params['data'])
开发者ID:bkbarry,项目名称:swagger-py,代码行数:17,代码来源:resource_model_test.py


示例20: test_success_on_correct_primitive_types_returned_by_operation

 def test_success_on_correct_primitive_types_returned_by_operation(self):
     types = {
         'void': '[]',
         'string': '"test"',
         'integer': '42',
         'number': '3.4',
         'boolean': 'true'
     }
     for type_ in types:
         self.response["apis"][0]["operations"][0]["type"] = type_
         self.register_urls()
         httpretty.register_uri(
             httpretty.GET, "http://localhost/test_http?test_param=foo",
             body=types[type_])
         resource = SwaggerClient(u'http://localhost/api-docs').api_test
         resp = resource.testHTTP(test_param="foo").result()
         self.assertEqual(json.loads(types[type_]), resp)
开发者ID:kfreedland,项目名称:swagger-py,代码行数:17,代码来源:resource_response_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python route_handler.register函数代码示例发布时间:2022-05-27
下一篇:
Python urllib.urlparse函数代码示例发布时间: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