Browse Source

Resolve import conflicts

Bastien Sevajol 6 years ago
parent
commit
1b0a105459

+ 1 - 1
.travis.yml View File

6
 
6
 
7
 install:
7
 install:
8
   - python setup.py develop
8
   - python setup.py develop
9
-  - pip install pytest pytest-cov python-coveralls
9
+  - pip install -e ."[test]"
10
 
10
 
11
 script: 
11
 script: 
12
   - pytest --cov=hapic tests
12
   - pytest --cov=hapic tests

+ 0 - 1
hapic/__init__.py View File

1
 # -*- coding: utf-8 -*-
1
 # -*- coding: utf-8 -*-
2
 from hapic.hapic import Hapic
2
 from hapic.hapic import Hapic
3
 from hapic.data import HapicData
3
 from hapic.data import HapicData
4
-from hapic import ext
5
 
4
 
6
 _hapic_default = Hapic()
5
 _hapic_default = Hapic()
7
 
6
 

+ 9 - 0
hapic/context.py View File

52
         :return: OpenAPI path
52
         :return: OpenAPI path
53
         """
53
         """
54
         raise NotImplementedError()
54
         raise NotImplementedError()
55
+
56
+    def by_pass_output_wrapping(self, response: typing.Any) -> bool:
57
+        """
58
+        Return True if the controller response is in final state: we do not
59
+        have to apply output wrapper on it.
60
+        :param response: the original response of controller
61
+        :return:
62
+        """
63
+        raise NotImplementedError()

+ 1 - 2
hapic/decorator.py View File

5
 
5
 
6
 # TODO BS 20171010: bottle specific !  # see #5
6
 # TODO BS 20171010: bottle specific !  # see #5
7
 import marshmallow
7
 import marshmallow
8
-from bottle import HTTPResponse
9
 from multidict import MultiDict
8
 from multidict import MultiDict
10
 
9
 
11
 from hapic.data import HapicData
10
 from hapic.data import HapicData
215
 
214
 
216
     def after_wrapped_function(self, response: typing.Any) -> typing.Any:
215
     def after_wrapped_function(self, response: typing.Any) -> typing.Any:
217
         try:
216
         try:
218
-            if isinstance(response, HTTPResponse):
217
+            if self.context.by_pass_output_wrapping(response):
219
                 return response
218
                 return response
220
 
219
 
221
             processed_response = self.processor.process(response)
220
             processed_response = self.processor.process(response)

+ 0 - 3
hapic/ext/__init__.py View File

1
 # -*- coding: utf-8 -*-
1
 # -*- coding: utf-8 -*-
2
-from hapic.ext import bottle
3
-from hapic.ext import pyramid
4
-from hapic.ext import flask

+ 5 - 0
hapic/ext/bottle/context.py View File

112
 
112
 
113
     def get_swagger_path(self, contextualised_rule: str) -> str:
113
     def get_swagger_path(self, contextualised_rule: str) -> str:
114
         return BOTTLE_RE_PATH_URL.sub(r'{\1}', contextualised_rule)
114
         return BOTTLE_RE_PATH_URL.sub(r'{\1}', contextualised_rule)
115
+
116
+    def by_pass_output_wrapping(self, response: typing.Any) -> bool:
117
+        if isinstance(response, bottle.HTTPResponse):
118
+            return True
119
+        return False

+ 3 - 0
hapic/ext/flask/context.py View File

101
     def get_swagger_path(self, contextualised_rule: str) -> str:
101
     def get_swagger_path(self, contextualised_rule: str) -> str:
102
         # TODO - G.M - 2017-12-05 Check if all route path are handled correctly
102
         # TODO - G.M - 2017-12-05 Check if all route path are handled correctly
103
         return FLASK_RE_PATH_URL.sub(r'{\1}', contextualised_rule)
103
         return FLASK_RE_PATH_URL.sub(r'{\1}', contextualised_rule)
104
+
105
+    def by_pass_output_wrapping(self, response: typing.Any) -> bool:
106
+        return False

+ 3 - 0
hapic/ext/pyramid/context.py View File

120
         # TODO BS 20171110: Pyramid allow route like '/{foo:\d+}', so adapt
120
         # TODO BS 20171110: Pyramid allow route like '/{foo:\d+}', so adapt
121
         # and USE regular expression (see https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/urldispatch.html#custom-route-predicates)  # nopep8
121
         # and USE regular expression (see https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/urldispatch.html#custom-route-predicates)  # nopep8
122
         return contextualised_rule
122
         return contextualised_rule
123
+
124
+    def by_pass_output_wrapping(self, response: typing.Any) -> bool:
125
+        return False

+ 1 - 5
setup.py View File

7
 here = path.abspath(path.dirname(__file__))
7
 here = path.abspath(path.dirname(__file__))
8
 
8
 
9
 install_requires = [
9
 install_requires = [
10
-    # TODO: Bottle will be an extension in future, see #1
11
-    # TODO: marshmallow an extension too ? see #2
12
-    'bottle',
13
     'marshmallow',
10
     'marshmallow',
14
     'apispec==0.27.1-algoo',
11
     'apispec==0.27.1-algoo',
15
     'multidict'
12
     'multidict'
25
     'webtest',
22
     'webtest',
26
 ]
23
 ]
27
 dev_require = [
24
 dev_require = [
28
-    'requests',
29
-]
25
+] + tests_require
30
 
26
 
31
 setup(
27
 setup(
32
     name='hapic',
28
     name='hapic',