| [3a89adb] | 1 | # coding: utf-8
|
|---|
| 2 |
|
|---|
| 3 | from __future__ import absolute_import
|
|---|
| 4 | import unittest
|
|---|
| 5 |
|
|---|
| 6 | from flask import json
|
|---|
| 7 | from six import BytesIO
|
|---|
| 8 |
|
|---|
| 9 | {{#imports}}{{import}} # noqa: E501
|
|---|
| 10 | {{/imports}}
|
|---|
| [ae2ff15] | 11 | from . import BaseTestCase
|
|---|
| [3a89adb] | 12 |
|
|---|
| 13 |
|
|---|
| 14 | class {{#operations}}Test{{classname}}(BaseTestCase):
|
|---|
| 15 | """{{classname}} integration test stubs"""
|
|---|
| 16 |
|
|---|
| 17 | {{#operation}}
|
|---|
| 18 | {{#vendorExtensions.x-skip-test}}
|
|---|
| 19 | @unittest.skip("{{reason}}")
|
|---|
| 20 | {{/vendorExtensions.x-skip-test}}
|
|---|
| 21 | def test_{{operationId}}(self):
|
|---|
| 22 | """Test case for {{{operationId}}}
|
|---|
| 23 |
|
|---|
| 24 | {{{summary}}}
|
|---|
| 25 | """
|
|---|
| 26 | {{#bodyParam}}
|
|---|
| 27 | {{paramName}} = {{{example}}}
|
|---|
| 28 | {{/bodyParam}}
|
|---|
| 29 | {{#queryParams}}
|
|---|
| [be25db1] | 30 | {{#-first}}query_string = [{{/-first}}{{^-first}} {{/-first}}('{{paramName}}', '{{{example}}}'){{#hasMore}},{{/hasMore}}{{#-last}}]{{/-last}}
|
|---|
| [3a89adb] | 31 | {{/queryParams}}
|
|---|
| 32 | headers = { {{#vendorExtensions.x-prefered-produce}}
|
|---|
| 33 | 'Accept': '{{mediaType}}',{{/vendorExtensions.x-prefered-produce}}{{#vendorExtensions.x-prefered-consume}}
|
|---|
| 34 | 'Content-Type': '{{mediaType}}',{{/vendorExtensions.x-prefered-consume}}{{#headerParams}}
|
|---|
| [be25db1] | 35 | '{{paramName}}': '{{{example}}}',{{/headerParams}}{{#authMethods}}
|
|---|
| [ae2ff15] | 36 | {{#isBasicBasic}}'Authorization': 'Basic YXV0b3Rlc3RzOmF1dG90ZXN0cw==',{{/isBasicBasic}}
|
|---|
| 37 | {{/authMethods}}
|
|---|
| [3a89adb] | 38 | }
|
|---|
| 39 | {{#formParams}}
|
|---|
| 40 | {{#-first}}data = dict({{/-first}}{{^-first}} {{/-first}}{{paramName}}={{{example}}}{{#hasMore}},{{/hasMore}}{{#-last}}){{/-last}}
|
|---|
| 41 | {{/formParams}}
|
|---|
| 42 | response = self.client.open(
|
|---|
| [be25db1] | 43 | '{{#contextPath}}{{{.}}}{{/contextPath}}{{{path}}}'{{#pathParams}}{{#-first}}.format({{/-first}}{{paramName}}='{{{example}}}'{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/pathParams}},
|
|---|
| [3a89adb] | 44 | method='{{httpMethod}}',
|
|---|
| 45 | headers=headers{{#bodyParam}},
|
|---|
| 46 | data=json.dumps({{paramName}}){{^consumes}},
|
|---|
| 47 | content_type='application/json'{{/consumes}}{{/bodyParam}}{{#formParams}}{{#-first}},
|
|---|
| 48 | data=data{{/-first}}{{/formParams}}{{#consumes}}{{#-first}},
|
|---|
| 49 | content_type='{{{mediaType}}}'{{/-first}}{{/consumes}}{{#queryParams}}{{#-first}},
|
|---|
| 50 | query_string=query_string{{/-first}}{{/queryParams}})
|
|---|
| 51 | self.assert200(response,
|
|---|
| 52 | 'Response body is : ' + response.data.decode('utf-8'))
|
|---|
| 53 |
|
|---|
| 54 | {{/operation}}
|
|---|
| 55 | {{/operations}}
|
|---|
| 56 |
|
|---|
| 57 | if __name__ == '__main__':
|
|---|
| 58 | unittest.main()
|
|---|