source: buildhelpers/codegen/templates/controller_test.mustache@ 0c8a692

debian/bullseye
Last change on this file since 0c8a692 was 43fd35c, checked in by Joachim Langenbach <joachim.langenbach@…>, 7 years ago

Refactored code to have one gnuboat python structure

  • Property mode set to 100644
File size: 2.4 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}}
[ae2ff15]11from . import BaseTestCase
[3a89adb]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 {{{summary}}}
24 """
25 {{#bodyParam}}
26 {{paramName}} = {{{example}}}
27 {{/bodyParam}}
28 {{#queryParams}}
[be25db1]29 {{#-first}}query_string = [{{/-first}}{{^-first}} {{/-first}}('{{paramName}}', '{{{example}}}'){{#hasMore}},{{/hasMore}}{{#-last}}]{{/-last}}
[3a89adb]30 {{/queryParams}}
31 headers = { {{#vendorExtensions.x-prefered-produce}}
32 'Accept': '{{mediaType}}',{{/vendorExtensions.x-prefered-produce}}{{#vendorExtensions.x-prefered-consume}}
33 'Content-Type': '{{mediaType}}',{{/vendorExtensions.x-prefered-consume}}{{#headerParams}}
[be25db1]34 '{{paramName}}': '{{{example}}}',{{/headerParams}}{{#authMethods}}
[ae2ff15]35 {{#isBasicBasic}}'Authorization': 'Basic YXV0b3Rlc3RzOmF1dG90ZXN0cw==',{{/isBasicBasic}}
36 {{/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.