source: src/mapservice/codegen/templates/controller_test.mustache@ 75f09e4

debian/bullseye
Last change on this file since 75f09e4 was be25db1, checked in by Joachim Langenbach <joachim.langenbach@…>, 8 years ago

Improved adding Water UI in mapservice-webclient

  • Property mode set to 100644
File size: 2.6 KB
RevLine 
[3a89adb]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 {{packageName}}.test 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}}
[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}}
36 {{#isOAuth}}'Authorization': 'Bearer special-key',{{/isOAuth}}{{#isApiKey}}'X-API-KEY': 'test_key',{{/isApiKey}}{{#isBasicBasic}}'Authorization': 'BasicZm9vOmJhcg==',{{/isBasicBasic}}{{#isBasicBearer}}'Authorization': 'Bearer special-key',{{/isBasicBearer}}{{/authMethods}}
[3a89adb]37 }
38 {{#formParams}}
39 {{#-first}}data = dict({{/-first}}{{^-first}} {{/-first}}{{paramName}}={{{example}}}{{#hasMore}},{{/hasMore}}{{#-last}}){{/-last}}
40 {{/formParams}}
41 response = self.client.open(
[be25db1]42 '{{#contextPath}}{{{.}}}{{/contextPath}}{{{path}}}'{{#pathParams}}{{#-first}}.format({{/-first}}{{paramName}}='{{{example}}}'{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/pathParams}},
[3a89adb]43 method='{{httpMethod}}',
44 headers=headers{{#bodyParam}},
45 data=json.dumps({{paramName}}){{^consumes}},
46 content_type='application/json'{{/consumes}}{{/bodyParam}}{{#formParams}}{{#-first}},
47 data=data{{/-first}}{{/formParams}}{{#consumes}}{{#-first}},
48 content_type='{{{mediaType}}}'{{/-first}}{{/consumes}}{{#queryParams}}{{#-first}},
49 query_string=query_string{{/-first}}{{/queryParams}})
50 self.assert200(response,
51 'Response body is : ' + response.data.decode('utf-8'))
52
53 {{/operation}}
54{{/operations}}
55
56if __name__ == '__main__':
57 unittest.main()
Note: See TracBrowser for help on using the repository browser.