当前位置: 首页>>代码示例>>Python>>正文


Python client.SwaggerClient类代码示例

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


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


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