當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。