All Downloads are FREE. Search and download functionalities are using the official Maven repository.

handlebars.pythonFlaskConnexion.controller_test.mustache Maven / Gradle / Ivy

There is a newer version: 1.0.54
Show newest version
# coding: utf-8

from __future__ import absolute_import

from flask import json
from six import BytesIO

{{#imports}}{{import}}  # noqa: E501
{{/imports}}
from {{packageName}}.test import BaseTestCase


class {{#operations}}Test{{classname}}(BaseTestCase):
    """{{classname}} integration test stubs"""

   {{#operation}}
    def test_{{operationId}}(self):
        """Test case for {{{operationId}}}

        {{{summary}}}
        """
        {{#bodyParam}}
        {{paramName}} = {{{example}}}
        {{/bodyParam}}
        {{#queryParams}}
        {{#@first}}query_string = [{{/@first}}{{^@first}}                {{/@first}}('{{paramName}}', {{{example}}}){{#hasMore}},{{/hasMore}}{{#@last}}]{{/@last}}
        {{/queryParams}}
        {{#headerParams}}
        {{#@first}}headers = [{{/@first}}{{^@first}}           {{/@first}}('{{paramName}}', {{{example}}}){{#hasMore}},{{/hasMore}}{{#@last}}]{{/@last}}
        {{/headerParams}}
        {{#formParams}}
        {{#@first}}data = dict({{/@first}}{{^@first}}            {{/@first}}{{paramName}}={{{example}}}{{#hasMore}},{{/hasMore}}{{#@last}}){{/@last}}
        {{/formParams}}
        response = self.client.open(
            '{{#contextPath}}{{{.}}}{{/contextPath}}{{{path}}}'{{#pathParams}}{{#@first}}.format({{/@first}}{{paramName}}={{{example}}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/pathParams}},
            method='{{httpMethod}}'{{#bodyParam}},
            data=json.dumps({{paramName}}){{^consumes}},
            content_type='application/json'{{/consumes}}{{/bodyParam}}{{#headerParams}}{{#@first}},
            headers=headers{{/@first}}{{/headerParams}}{{#formParams}}{{#@first}},
            data=data{{/@first}}{{/formParams}}{{#consumes}}{{#@first}},
            content_type='{{{mediaType}}}'{{/@first}}{{/consumes}}{{#queryParams}}{{#@first}},
            query_string=query_string{{/@first}}{{/queryParams}})
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))

   {{/operation}}
{{/operations}}

if __name__ == '__main__':
    import unittest
    unittest.main()




© 2015 - 2024 Weber Informatics LLC | Privacy Policy