source: src/mapservice/codegen/templates/controller_test.mustache@ f61d16d

debian/bullseye
Last change on this file since f61d16d was ae2ff15, checked in by Joachim Langenbach <joachim.langenbach@…>, 7 years ago
  • Fixed testing environment
    • Fixed some issues in the API and it's serving
  • Property mode set to 100644
File size: 2.4 KB
Line 
1# coding: utf-8
2
3from __future__ import absolute_import
4import unittest
5
6from flask import json
7from six import BytesIO
8
9{{#imports}}{{import}} # noqa: E501
10{{/imports}}
11from . import BaseTestCase
12
13
14class {{#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}}
30 {{#-first}}query_string = [{{/-first}}{{^-first}} {{/-first}}('{{paramName}}', '{{{example}}}'){{#hasMore}},{{/hasMore}}{{#-last}}]{{/-last}}
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}}
35 '{{paramName}}': '{{{example}}}',{{/headerParams}}{{#authMethods}}
36 {{#isBasicBasic}}'Authorization': 'Basic YXV0b3Rlc3RzOmF1dG90ZXN0cw==',{{/isBasicBasic}}
37 {{/authMethods}}
38 }
39 {{#formParams}}
40 {{#-first}}data = dict({{/-first}}{{^-first}} {{/-first}}{{paramName}}={{{example}}}{{#hasMore}},{{/hasMore}}{{#-last}}){{/-last}}
41 {{/formParams}}
42 response = self.client.open(
43 '{{#contextPath}}{{{.}}}{{/contextPath}}{{{path}}}'{{#pathParams}}{{#-first}}.format({{/-first}}{{paramName}}='{{{example}}}'{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/pathParams}},
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
57if __name__ == '__main__':
58 unittest.main()
Note: See TracBrowser for help on using the repository browser.