appier 1.34.5__py2.py3-none-any.whl → 1.34.7__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
appier/__init__.py CHANGED
@@ -78,7 +78,7 @@ from .asynchronous import (
78
78
  QueueManager,
79
79
  AwaitWrapper,
80
80
  CoroutineWrapper,
81
- AyncgenWrapper,
81
+ AsyncgenWrapper,
82
82
  await_wrap,
83
83
  await_yield,
84
84
  ensure_generator,
appier/async_neo.py CHANGED
@@ -92,7 +92,7 @@ class CoroutineWrapper(object):
92
92
  self._buffer.append(value)
93
93
 
94
94
 
95
- class AyncgenWrapper(object):
95
+ class AsyncgenWrapper(object):
96
96
  def __init__(self, async_iter):
97
97
  self.async_iter = async_iter
98
98
  self.current = None
@@ -149,7 +149,7 @@ def ensure_generator(value):
149
149
  if hasattr(inspect, "isasyncgen") and inspect.isasyncgen(
150
150
  value
151
151
  ): # @UndefinedVariable
152
- return True, AyncgenWrapper(value)
152
+ return True, AsyncgenWrapper(value)
153
153
 
154
154
  return False, value
155
155
 
appier/async_old.py CHANGED
@@ -179,7 +179,7 @@ class CoroutineWrapper(object):
179
179
  pass
180
180
 
181
181
 
182
- class AyncgenWrapper(object):
182
+ class AsyncgenWrapper(object):
183
183
  pass
184
184
 
185
185
 
appier/base.py CHANGED
@@ -94,7 +94,7 @@ NAME = "appier"
94
94
  """ The name to be used to describe the framework while working
95
95
  on its own environment, this is just a descriptive value """
96
96
 
97
- VERSION = "1.34.5"
97
+ VERSION = "1.34.7"
98
98
  """ The version of the framework that is currently installed
99
99
  this value may be used for debugging/diagnostic purposes """
100
100
 
@@ -1781,7 +1781,7 @@ class App(
1781
1781
  # so that class level operations may be performed
1782
1782
  cls = self.__class__
1783
1783
 
1784
- # tries to ensure that the UID value of the exception is set,
1784
+ # tries to ensure that the UUID value of the exception is set,
1785
1785
  # notice that under some extreme occasions it may not be possible
1786
1786
  # to ensure such behavior (eg: native code based exception)
1787
1787
  if not hasattr(exception, "uid"):
@@ -1821,6 +1821,10 @@ class App(
1821
1821
  # "raised" by the current exception object in handling
1822
1822
  self.request.set_headers(headers)
1823
1823
 
1824
+ # sets the additional error trace identifier header in the request, to allow
1825
+ # extra debug support for the error
1826
+ self.request.set_header("X-Error-Id", exception.uid)
1827
+
1824
1828
  # runs the on error processor in the base application object and in case
1825
1829
  # a value is returned by a possible handler it is used as the response
1826
1830
  # for the current request (instead of the normal handler)
@@ -2232,7 +2236,7 @@ class App(
2232
2236
  def warning(self, message):
2233
2237
  self.request.warning(message)
2234
2238
 
2235
- def redirect(self, url, code=303, params=None, **kwargs):
2239
+ def redirect(self, url, code=303, relative=False, params=None, **kwargs):
2236
2240
  # in case there are no explicit parameters provided then the
2237
2241
  # named arguments should be used instead
2238
2242
  if params == None:
@@ -2244,6 +2248,15 @@ class App(
2244
2248
  if query:
2245
2249
  url += ("&" if "?" in url else "?") + query
2246
2250
 
2251
+ # in case a relative URL is expected, makes sure we enforce one
2252
+ # preventing possible absolute URL redirections
2253
+ if relative:
2254
+ is_absolute = url.startswith(("http://", "https://", "//"))
2255
+ if is_absolute:
2256
+ raise exceptions.SecurityError(
2257
+ message="Attempt to redirect to absolute URL", code=401
2258
+ )
2259
+
2247
2260
  # sets both the (redirection) code and the new location URL
2248
2261
  # values in the current request (response) object
2249
2262
  self.request.code = code
@@ -2454,11 +2467,7 @@ class App(
2454
2467
 
2455
2468
  parameters = dict(kwargs)
2456
2469
  parameters.update(
2457
- sender=sender,
2458
- receivers=receivers,
2459
- cc=cc,
2460
- bcc=bcc,
2461
- subject=subject,
2470
+ sender=sender, receivers=receivers, cc=cc, bcc=bcc, subject=subject
2462
2471
  )
2463
2472
 
2464
2473
  if html == None:
@@ -4065,9 +4074,7 @@ class App(
4065
4074
  # is possible raises a not found error
4066
4075
  part_s = self.get_part(part)
4067
4076
  if not part_s:
4068
- raise exceptions.NotFoundError(
4069
- message="Part not found '%s'" % part,
4070
- )
4077
+ raise exceptions.NotFoundError(message="Part not found '%s'" % part)
4071
4078
 
4072
4079
  # sends the static information taking into account the
4073
4080
  # provided data and the base static path of the part
@@ -6131,7 +6138,10 @@ class App(
6131
6138
  continue
6132
6139
  if _handler[1] and not scope == _handler[1]:
6133
6140
  continue
6134
- if not json == _handler[2]:
6141
+ # if the handler has explicitly defined to handle JSON
6142
+ # contexts then it should only be used if the JSON flag
6143
+ # is also set to the same value as in the handler
6144
+ if not _handler[2] == None and not json == _handler[2]:
6135
6145
  continue
6136
6146
  handler = _handler
6137
6147
  break
@@ -6576,6 +6586,10 @@ class WebApp(App):
6576
6586
  # "raised" by the current exception object in handling
6577
6587
  self.request.set_headers(headers)
6578
6588
 
6589
+ # sets the additional error trace identifier header in the request, to allow
6590
+ # extra debug support for the error
6591
+ self.request.set_header("X-Error-Id", exception.uid)
6592
+
6579
6593
  # run the on error processor in the base application object and in case
6580
6594
  # a value is returned by a possible handler it is used as the response
6581
6595
  # for the current request (instead of the normal handler)
appier/config.py CHANGED
@@ -163,10 +163,7 @@ def load(names=(FILE_NAME,), path=None, encoding="utf-8", ctx=None):
163
163
  paths = []
164
164
  homes = get_homes()
165
165
  for home in homes:
166
- paths += [
167
- os.path.join(home),
168
- os.path.join(home, ".config"),
169
- ]
166
+ paths += [os.path.join(home), os.path.join(home, ".config")]
170
167
  paths += [sys.prefix]
171
168
  paths.append(path)
172
169
  for path in paths:
appier/data.py CHANGED
@@ -204,6 +204,8 @@ class TinyAdapter(DataAdapter):
204
204
  return tinydb.TinyDB(storage=tinydb.storages.MemoryStorage)
205
205
 
206
206
  def _drop_db_json(self):
207
+ if not os.path.exists(self.file_path):
208
+ return
207
209
  os.remove(self.file_path)
208
210
 
209
211
  def _drop_db_memory(self):
appier/model.py CHANGED
@@ -148,10 +148,7 @@ so that they are lazy loaded from the data source, these kind
148
148
  of types should be compliant to a common interface so that they
149
149
  may be used "blindly" from an external entity """
150
150
 
151
- REVERSE = dict(
152
- descending="ascending",
153
- ascending="descending",
154
- )
151
+ REVERSE = dict(descending="ascending", ascending="descending")
155
152
  """ The reverse order dictionary that maps a certain
156
153
  order direction (as a string) with the opposite one
157
154
  this may be used to "calculate" the reverse value """
@@ -357,6 +354,7 @@ class Model(legacy.with_meta(meta.Ordered, observer.Observable, *EXTRA_CLS)):
357
354
  safe=True,
358
355
  build=False,
359
356
  fill=True,
357
+ fill_safe=False,
360
358
  new=True,
361
359
  **kwargs
362
360
  ):
@@ -398,7 +396,11 @@ class Model(legacy.with_meta(meta.Ordered, observer.Observable, *EXTRA_CLS)):
398
396
  injected into the resulting instance.
399
397
  :type fill: bool
400
398
  :param fill: If the various attributes of the model should be "filled"
401
- with default values (avoiding empty values).
399
+ with default values (avoiding empty values), not going to be applied to
400
+ safe attributes.
401
+ :type fill_safe: bool
402
+ :param fill_safe: If the safe values should also be "filled" meaning that
403
+ they are initialized in a forced "way".
402
404
  :type new: bool
403
405
  :param new: In case this value is valid the resulting instance is expected
404
406
  to be considered as new meaning that no identifier attributes are set.
@@ -411,7 +413,7 @@ class Model(legacy.with_meta(meta.Ordered, observer.Observable, *EXTRA_CLS)):
411
413
  model = util.get_object() if form else dict(kwargs)
412
414
  if fill:
413
415
  model = cls.fill(model, safe=not new)
414
- instance = cls(fill=False)
416
+ instance = cls(fill=fill_safe)
415
417
  instance.apply(model, form=form, safe_a=safe)
416
418
  if build:
417
419
  cls.build(instance.model, map=False)
appier/test/base.py CHANGED
@@ -173,7 +173,7 @@ class BaseTest(unittest.TestCase):
173
173
  invalid_email=["john"],
174
174
  valid_length=["1234"],
175
175
  invalid_length=["12345"],
176
- ),
176
+ )
177
177
  )
178
178
  self.app._request = request
179
179
 
@@ -369,10 +369,7 @@ class BaseTest(unittest.TestCase):
369
369
  self.skipTest("No Jinja2 template engine present")
370
370
 
371
371
  self.app._register_bundle(
372
- {
373
- "hello": appier.legacy.u("olá"),
374
- "world": appier.legacy.u("mundo"),
375
- },
372
+ {"hello": appier.legacy.u("olá"), "world": appier.legacy.u("mundo")},
376
373
  "pt_pt",
377
374
  )
378
375
 
appier/test/data.py CHANGED
@@ -28,6 +28,8 @@ __copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
28
28
  __license__ = "Apache License, Version 2.0"
29
29
  """ The license for the module """
30
30
 
31
+ import os
32
+ import tempfile
31
33
  import unittest
32
34
 
33
35
  import appier
@@ -40,3 +42,11 @@ class DataTest(unittest.TestCase):
40
42
 
41
43
  self.assertEqual(type(identifier), str)
42
44
  self.assertEqual(len(identifier), 24)
45
+
46
+ def test_drop_db_missing(self):
47
+ fd, file_path = tempfile.mkstemp()
48
+ os.close(fd)
49
+ adapter = appier.TinyAdapter(file_path=file_path)
50
+ adapter.get_db()
51
+ os.remove(file_path)
52
+ adapter.drop_db()
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ # Hive Appier Framework
5
+ # Copyright (c) 2008-2024 Hive Solutions Lda.
6
+ #
7
+ # This file is part of Hive Appier Framework.
8
+ #
9
+ # Hive Appier Framework is free software: you can redistribute it and/or modify
10
+ # it under the terms of the Apache License as published by the Apache
11
+ # Foundation, either version 2.0 of the License, or (at your option) any
12
+ # later version.
13
+ #
14
+ # Hive Appier Framework is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # Apache License for more details.
18
+ #
19
+ # You should have received a copy of the Apache License along with
20
+ # Hive Appier Framework. If not, see <http://www.apache.org/licenses/>.
21
+
22
+ __author__ = "João Magalhães <joamag@hive.pt>"
23
+ """ The author(s) of the module """
24
+
25
+ __copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
26
+ """ The copyright for the module """
27
+
28
+ __license__ = "Apache License, Version 2.0"
29
+ """ The license for the module """
30
+
31
+ import unittest
32
+
33
+ import appier
34
+
35
+
36
+ class ErrorHandlerTest(unittest.TestCase):
37
+ def setUp(self):
38
+ self._original_handlers = appier.common.base().App._ERROR_HANDLERS
39
+ appier.common.base().App._ERROR_HANDLERS = {}
40
+ self.app = appier.App()
41
+
42
+ def tearDown(self):
43
+ self.app.unload()
44
+ appier.common.base().App._ERROR_HANDLERS = self._original_handlers
45
+
46
+ def test_basic_registration_and_call(self):
47
+ """
48
+ Decorator should register the handler and it must be invoked by
49
+ :pyfunc:`appier.App.call_error` when an exception matching the provided
50
+ error code is raised.
51
+
52
+ The error handler is a JSON handler by default, to be able to properly
53
+ handle errors in an App.
54
+ """
55
+
56
+ expected_message = "resource not found"
57
+
58
+ @appier.error_handler(404, json=True)
59
+ def not_found(_):
60
+ return expected_message
61
+
62
+ exc = appier.exceptions.NotFoundError("dummy")
63
+ result = self.app.call_error(exc, code=exc.code, scope=None, json=True)
64
+
65
+ self.assertEqual(result, expected_message)
66
+
67
+ handlers = appier.common.base().App._ERROR_HANDLERS.get(404)
68
+ self.assertNotEqual(handlers, None)
69
+ self.assertEqual(len(handlers), 1)
70
+
71
+ method, scope, json, opts, ctx, priority = handlers[0]
72
+ self.assertEqual(method, not_found)
73
+ self.assertEqual(scope, None)
74
+ self.assertEqual(json, True)
75
+ self.assertEqual(opts, None)
76
+ self.assertEqual(ctx, None)
77
+ self.assertEqual(priority, 1)
78
+
79
+ def test_web_handler(self):
80
+ """
81
+ Test that in which the error handler is a web handler by default, to be
82
+ able to properly handle errors in an WebApp, because this is a App no
83
+ handler is called.
84
+ """
85
+
86
+ expected_message = "resource not found"
87
+
88
+ @appier.error_handler(404, json=False)
89
+ def not_found(_):
90
+ return expected_message
91
+
92
+ exc = appier.exceptions.NotFoundError("dummy")
93
+ result = self.app.call_error(exc, code=exc.code, scope=None, json=True)
94
+
95
+ self.assertEqual(result, None)
96
+
97
+ handlers = appier.common.base().App._ERROR_HANDLERS.get(404)
98
+ self.assertNotEqual(handlers, None)
99
+ self.assertEqual(len(handlers), 1)
100
+
101
+ method, scope, json, opts, ctx, priority = handlers[0]
102
+ self.assertEqual(method, not_found)
103
+ self.assertEqual(scope, None)
104
+ self.assertEqual(json, False)
105
+ self.assertEqual(opts, None)
106
+ self.assertEqual(ctx, None)
107
+ self.assertEqual(priority, 1)
108
+
109
+ def test_scope_registration(self):
110
+ """
111
+ When a *scope* argument is provided, it should be stored in the handler
112
+ metadata so that the framework can later match it appropriately.
113
+
114
+ The error handler is a JSON handler by default, to be able to properly
115
+ handle errors in an App.
116
+ """
117
+
118
+ class DummyScope:
119
+ pass
120
+
121
+ @appier.error_handler(400, scope=DummyScope, json=True)
122
+ def bad_request(_):
123
+ return "bad request"
124
+
125
+ handlers = appier.common.base().App._ERROR_HANDLERS.get(400)
126
+ self.assertNotEqual(handlers, None)
127
+ self.assertEqual(len(handlers), 1)
128
+
129
+ method, scope, json, opts, ctx, priority = handlers[0]
130
+
131
+ self.assertEqual(method, bad_request)
132
+ self.assertEqual(scope, DummyScope)
133
+ self.assertEqual(json, True)
134
+ self.assertEqual(opts, None)
135
+ self.assertEqual(ctx, None)
136
+ self.assertEqual(priority, 1)
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ # Hive Appier Framework
5
+ # Copyright (c) 2008-2024 Hive Solutions Lda.
6
+ #
7
+ # This file is part of Hive Appier Framework.
8
+ #
9
+ # Hive Appier Framework is free software: you can redistribute it and/or modify
10
+ # it under the terms of the Apache License as published by the Apache
11
+ # Foundation, either version 2.0 of the License, or (at your option) any
12
+ # later version.
13
+ #
14
+ # Hive Appier Framework is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # Apache License for more details.
18
+ #
19
+ # You should have received a copy of the Apache License along with
20
+ # Hive Appier Framework. If not, see <http://www.apache.org/licenses/>.
21
+
22
+ __author__ = "João Magalhães <joamag@hive.pt>"
23
+ """ The author(s) of the module """
24
+
25
+ __copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
26
+ """ The copyright for the module """
27
+
28
+ __license__ = "Apache License, Version 2.0"
29
+ """ The license for the module """
30
+
31
+ import unittest
32
+
33
+ import appier
34
+
35
+
36
+ class ExceptionHandlerTest(unittest.TestCase):
37
+ def setUp(self):
38
+ self._original_handlers = appier.common.base().App._ERROR_HANDLERS
39
+ appier.common.base().App._ERROR_HANDLERS = {}
40
+ self.app = appier.App()
41
+
42
+ def tearDown(self):
43
+ self.app.unload()
44
+ appier.common.base().App._ERROR_HANDLERS = self._original_handlers
45
+
46
+ def test_basic_registration_and_call(self):
47
+ """
48
+ Decorator should register the handler and it must be invoked by
49
+ :pyfunc:`appier.App.call_error` when an exception matching the provided
50
+ type is raised.
51
+
52
+ The exception handler is a JSON handler by default, to be able to properly
53
+ handle errors in an App.
54
+ """
55
+
56
+ expected_message = "resource not found"
57
+
58
+ @appier.exception_handler(appier.exceptions.NotFoundError, json=True)
59
+ def not_found(_):
60
+ return expected_message
61
+
62
+ exc = appier.exceptions.NotFoundError("dummy")
63
+ result = self.app.call_error(exc, code=exc.code, scope=None, json=True)
64
+
65
+ self.assertEqual(result, expected_message)
66
+
67
+ handlers = appier.common.base().App._ERROR_HANDLERS.get(
68
+ appier.exceptions.NotFoundError
69
+ )
70
+ self.assertNotEqual(handlers, None)
71
+ self.assertEqual(len(handlers), 1)
72
+
73
+ method, scope, json, opts, ctx, priority = handlers[0]
74
+ self.assertEqual(method, not_found)
75
+ self.assertEqual(scope, None)
76
+ self.assertEqual(json, True)
77
+ self.assertEqual(opts, None)
78
+ self.assertEqual(ctx, None)
79
+ self.assertEqual(priority, 1)
80
+
81
+ def test_scope_registration(self):
82
+ """
83
+ When a *scope* argument is provided, it should be stored in the handler
84
+ metadata so that the framework can later match it appropriately.
85
+
86
+ The exception handler is a JSON handler by default, to be able to properly
87
+ handle errors in an App.
88
+ """
89
+
90
+ class DummyScope:
91
+ pass
92
+
93
+ class DummyException(Exception):
94
+ code = 400
95
+
96
+ @appier.exception_handler(DummyException, scope=DummyScope, json=True)
97
+ def dummy_handler(_):
98
+ return "dummy"
99
+
100
+ handlers = appier.common.base().App._ERROR_HANDLERS.get(DummyException)
101
+ self.assertNotEqual(handlers, None)
102
+ self.assertEqual(len(handlers), 1)
103
+
104
+ method, scope, json, opts, ctx, priority = handlers[0]
105
+
106
+ self.assertEqual(method, dummy_handler)
107
+ self.assertEqual(scope, DummyScope)
108
+ self.assertEqual(json, True)
109
+ self.assertEqual(opts, None)
110
+ self.assertEqual(ctx, None)
111
+ self.assertEqual(priority, 1)
112
+
113
+ def test_web_handler(self):
114
+ """
115
+ Test that in which the exception handler is a web handler by default, to be
116
+ able to properly handle errors in an WebApp, because this is an App no
117
+ handler is called.
118
+ """
119
+
120
+ expected_message = "resource not found"
121
+
122
+ @appier.exception_handler(appier.exceptions.NotFoundError, json=False)
123
+ def not_found(_):
124
+ return expected_message
125
+
126
+ exc = appier.exceptions.NotFoundError("dummy")
127
+ result = self.app.call_error(exc, code=exc.code, scope=None, json=True)
128
+
129
+ self.assertEqual(result, None)
130
+
131
+ handlers = appier.common.base().App._ERROR_HANDLERS.get(
132
+ appier.exceptions.NotFoundError
133
+ )
134
+ self.assertNotEqual(handlers, None)
135
+ self.assertEqual(len(handlers), 1)
136
+
137
+ method, scope, json, opts, ctx, priority = handlers[0]
138
+ self.assertEqual(method, not_found)
139
+ self.assertEqual(scope, None)
140
+ self.assertEqual(json, False)
141
+ self.assertEqual(opts, None)
142
+ self.assertEqual(ctx, None)
143
+ self.assertEqual(priority, 1)
appier/test/http.py CHANGED
@@ -104,6 +104,9 @@ class HTTPTest(unittest.TestCase):
104
104
  self.assertEqual(params, dict(hello=["world"]))
105
105
 
106
106
  def test_redirect(self):
107
+ if appier.conf("NO_NETWORK", False, cast=bool):
108
+ self.skipTest("Network access is disabled")
109
+
107
110
  _data, response = appier.get(
108
111
  "https://%s/redirect-to" % self.httpbin,
109
112
  params=dict(url="https://%s/" % self.httpbin),
@@ -135,6 +138,9 @@ class HTTPTest(unittest.TestCase):
135
138
  self.assertEqual(code, 200)
136
139
 
137
140
  def test_timeout(self):
141
+ if appier.conf("NO_NETWORK", False, cast=bool):
142
+ self.skipTest("Network access is disabled")
143
+
138
144
  self.assertRaises(
139
145
  BaseException,
140
146
  lambda: appier.get(
@@ -155,6 +161,9 @@ class HTTPTest(unittest.TestCase):
155
161
  self.assertNotEqual(data, None)
156
162
 
157
163
  def test_get_f(self):
164
+ if appier.conf("NO_NETWORK", False, cast=bool):
165
+ self.skipTest("Network access is disabled")
166
+
158
167
  file = appier.get_f("https://%s/image/png" % self.httpbin)
159
168
 
160
169
  self.assertEqual(file.file_name, "default")
@@ -170,6 +179,9 @@ class HTTPTest(unittest.TestCase):
170
179
  self.assertEqual(len(file.data_b64) > 100, True)
171
180
 
172
181
  def test_generator(self):
182
+ if appier.conf("NO_NETWORK", False, cast=bool):
183
+ self.skipTest("Network access is disabled")
184
+
173
185
  def text_g(message=[b"hello", b" ", b"world"]):
174
186
  yield sum(len(value) for value in message)
175
187
  for value in message:
@@ -185,6 +197,9 @@ class HTTPTest(unittest.TestCase):
185
197
  self.assertEqual(data["data"], "hello world")
186
198
 
187
199
  def test_file(self):
200
+ if appier.conf("NO_NETWORK", False, cast=bool):
201
+ self.skipTest("Network access is disabled")
202
+
188
203
  data, response = appier.post(
189
204
  "https://%s/post" % self.httpbin,
190
205
  data=appier.legacy.BytesIO(b"hello world"),
@@ -198,6 +213,9 @@ class HTTPTest(unittest.TestCase):
198
213
  self.assertEqual(data["data"], "hello world")
199
214
 
200
215
  def test_multithread(self):
216
+ if appier.conf("NO_NETWORK", False, cast=bool):
217
+ self.skipTest("Network access is disabled")
218
+
201
219
  threads = []
202
220
  results = []
203
221
 
@@ -230,11 +248,17 @@ class HTTPTest(unittest.TestCase):
230
248
  self.assertEqual(code, 200)
231
249
 
232
250
  def test_error(self):
251
+ if appier.conf("NO_NETWORK", False, cast=bool):
252
+ self.skipTest("Network access is disabled")
253
+
233
254
  self.assertRaises(
234
255
  appier.HTTPError, lambda: appier.get("https://%s/status/404" % self.httpbin)
235
256
  )
236
257
 
237
258
  def test_invalid(self):
259
+ if appier.conf("NO_NETWORK", False, cast=bool):
260
+ self.skipTest("Network access is disabled")
261
+
238
262
  self.assertRaises(
239
263
  BaseException, lambda: appier.get("https://invalidlargedomain.org/")
240
264
  )
appier/test/util.py CHANGED
@@ -555,11 +555,7 @@ class UtilTest(unittest.TestCase):
555
555
  self.assertEqual(type(result), list)
556
556
  self.assertEqual(result, [])
557
557
 
558
- result = appier.email_base(
559
- [
560
- appier.legacy.u(""),
561
- ]
562
- )
558
+ result = appier.email_base([appier.legacy.u("")])
563
559
  self.assertEqual(type(result), list)
564
560
  self.assertEqual(result, [])
565
561
 
@@ -582,8 +578,7 @@ class UtilTest(unittest.TestCase):
582
578
  raise appier.OperationalError(message="hello")
583
579
 
584
580
  struct = appier.lazy_dict(
585
- first=appier.lazy(lambda: raiser()),
586
- second=appier.lazy(lambda: 2),
581
+ first=appier.lazy(lambda: raiser()), second=appier.lazy(lambda: 2)
587
582
  )
588
583
 
589
584
  errors = appier.gather_errors(struct)
@@ -1077,15 +1072,7 @@ class UtilTest(unittest.TestCase):
1077
1072
  ),
1078
1073
  )
1079
1074
 
1080
- first = {
1081
- "info": {
1082
- "personal": {
1083
- "general": {
1084
- "kind": "human",
1085
- }
1086
- }
1087
- }
1088
- }
1075
+ first = {"info": {"personal": {"general": {"kind": "human"}}}}
1089
1076
  second = {
1090
1077
  "info": {
1091
1078
  "personal": {"general": {"kind": "cat", "tail": "long", "meaw": 12}},
appier/util.py CHANGED
@@ -68,12 +68,7 @@ ALL_CAP_REGEX = re.compile(r"([a-z0-9])([A-Z])")
68
68
  upper case letter regex that will provide a way of
69
69
  putting the underscore in the middle of the transition """
70
70
 
71
- SORT_MAP = {
72
- "1": 1,
73
- "-1": -1,
74
- "ascending": 1,
75
- "descending": -1,
76
- }
71
+ SORT_MAP = {"1": 1, "-1": -1, "ascending": 1, "descending": -1}
77
72
  """ The map associating the normalized (text) way of
78
73
  representing sorting with the current infra-structure
79
74
  number way of representing the same information """
@@ -2150,13 +2145,13 @@ def route(url, method="GET", asynchronous=False, json=False, opts=None, priority
2150
2145
  return decorator
2151
2146
 
2152
2147
 
2153
- def error_handler(code, scope=None, json=False, opts=None, priority=1):
2148
+ def error_handler(code, scope=None, json=None, opts=None, priority=1):
2154
2149
  def decorator(function, *args, **kwargs):
2155
2150
  if is_detached(function):
2156
2151
  delay(function, *args, **kwargs)
2157
2152
  else:
2158
2153
  common.base().App.add_error(
2159
- code, function, json=json, opts=opts, priority=priority
2154
+ code, function, scope=scope, json=json, opts=opts, priority=priority
2160
2155
  )
2161
2156
  return function
2162
2157
 
@@ -2173,13 +2168,18 @@ def error_handler(code, scope=None, json=False, opts=None, priority=1):
2173
2168
  return decorator
2174
2169
 
2175
2170
 
2176
- def exception_handler(exception, scope=None, json=False, opts=None, priority=1):
2171
+ def exception_handler(exception, scope=None, json=None, opts=None, priority=1):
2177
2172
  def decorator(function, *args, **kwargs):
2178
2173
  if is_detached(function):
2179
2174
  delay(function, *args, **kwargs)
2180
2175
  else:
2181
2176
  common.base().App.add_exception(
2182
- exception, function, json=json, opts=opts, priority=priority
2177
+ exception,
2178
+ function,
2179
+ scope=scope,
2180
+ json=json,
2181
+ opts=opts,
2182
+ priority=priority,
2183
2183
  )
2184
2184
  return function
2185
2185
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: appier
3
- Version: 1.34.5
3
+ Version: 1.34.7
4
4
  Summary: Appier Framework
5
5
  Home-page: http://appier.hive.pt
6
6
  Author: Hive Solutions Lda.
@@ -1,12 +1,12 @@
1
- appier/__init__.py,sha256=-Xd1j5egjwXV6yoKAkcPVWIZEnpPK_SJTTmQjDrW93E,9413
1
+ appier/__init__.py,sha256=08H8QW5pI-hvrdOAjeNem3Z2MgVxMbsTr0lbi7UCSt0,9414
2
2
  appier/amqp.py,sha256=etYxUlfaK27Og_9FJ6qCgNLSYhnz9XgVhIhSmD2ITW4,3852
3
3
  appier/api.py,sha256=s5ZJs0tgR3wktAhLZ7Vuhbd_4lWPsGJSEx0ptkqLxvM,14369
4
4
  appier/asgi.py,sha256=XqlXJ5QEyWyZBqFU9ubEx-jNehicihKcACR4Hy2A2nE,12194
5
- appier/async_neo.py,sha256=gQpyT1-nZE6Uynh5FEmFl5kfXkxChdUsgiKgwlaNw5E,5446
6
- appier/async_old.py,sha256=m3BFqHVPCRuIZ9L2sGYhCQPEwuCNKBO2y7SKM0dbtj8,9194
5
+ appier/async_neo.py,sha256=CqeVtKczXt3SZPvi0BYLujVTeN4i-sT8P1_0JPR5aiI,5448
6
+ appier/async_old.py,sha256=83YuTmoZkLIeyNHLZusCXqxB_6onRmYdKJ-Sqd1Yi1E,9195
7
7
  appier/asynchronous.py,sha256=a1LQa3wbGMaXELhF7W71dRr1klPOj6x-ST9EInvPhtU,1757
8
8
  appier/asynchronous.pyi,sha256=5CpLkpKcUq09woMOVYwpl24Pli0A8Xu6nXoT20xDQ-o,104
9
- appier/base.py,sha256=LuPVRAq1tP_dEfZ928CHdo2bzpS_ScqLl1n6xEpkEJY,270665
9
+ appier/base.py,sha256=WkvvOti2s3I4dAtZuOilBzQ4zNzHO9twDmK4o7D5j8c,271615
10
10
  appier/base.pyi,sha256=CwhdTt6lVGiXsXQewN1kkISD1YRNPCUf9U8fxYUVI3E,2924
11
11
  appier/bus.py,sha256=AMC2UXlaf6rzhzlIyTHkzbfb6tdfPBiOii4lpl9AAwg,7670
12
12
  appier/bus.pyi,sha256=W6_MIBpvDq468wfT5XM2WpPuR3O49QiZMOSCdMsJWos,182
@@ -16,10 +16,10 @@ appier/common.py,sha256=fcECBvu-KcB9DImZzkpM_FA_PUqgCx0FKP4KHuOikYc,1313
16
16
  appier/component.py,sha256=I6xDQp0dmYOarOgbyrXIfXa1RAsVHttd8JjUub15U2M,2988
17
17
  appier/component.pyi,sha256=zKO71mWgi7I8QapKajZHoWznrLyofHigCT4gJvDY3G8,22
18
18
  appier/compress.py,sha256=o3E-at5DjpW2s3uOljEqqfLLyPzEU9cSXHFISk0sPvA,4699
19
- appier/config.py,sha256=C9cgAViSm9QIMVoB-0cv-u12y8rKHpVC3D7WZMRJsxM,11568
19
+ appier/config.py,sha256=4DPhDJlb8frV2gZwLFD05mbUol7Z2-_oaeMV5oZWayw,11530
20
20
  appier/controller.py,sha256=uKzPJnz6aqibspPKf4tfJRvVMtxdDv0RFb0ivcDoepU,2285
21
21
  appier/crypt.py,sha256=Kr7Rbil8_bUp-oE_c_Wu2LRgk8nmVb9ukCHSuXE7RSc,5874
22
- appier/data.py,sha256=VIKRNME_SQGm-KzX3-FDwktWTosXAy2i92I1s1GqlGY,14696
22
+ appier/data.py,sha256=inrM-kXXsx0jLqyetXMWdBuobZbAWBH1fnShV4NcW-Y,14764
23
23
  appier/data.pyi,sha256=Er8SxhlZln9ghI4krKJnbFVajqxUVvad2_dgap_K80A,201
24
24
  appier/defines.py,sha256=47Ceno-haMlNplk4J5TRoeWM36ggr12_Qz9fkn8wrcE,10940
25
25
  appier/exceptions.py,sha256=H7teYBUSNn7-3SBGOSK7QxT6Mn--E5F2RpC8JSpiu5c,14089
@@ -36,7 +36,7 @@ appier/legacy.py,sha256=o_oJ_2lqZELZKwkvfGt0aDam6ZSZiZiL7FYygNjrDbY,15881
36
36
  appier/log.py,sha256=jhV7ub5nZwrLzY7x-tZDJfb8tcsXu-ndWxxrCspBUdU,12825
37
37
  appier/meta.py,sha256=rgBLOjD6QU9CGYsbCQS3Fy4iY14uk1-Kd8ljkfmxxzc,7168
38
38
  appier/mock.py,sha256=WoWa67rb8qV_ogToQJCdT0R-rCw9RUY24EkA4bYR1G4,5800
39
- appier/model.py,sha256=bvqmwsK4B0A-H_ULvsHzQ4qqlQTEousVsjhZcBjOS84,121893
39
+ appier/model.py,sha256=KTyAdLgxhbRlIUhuFtKysblw4JRZNnAm0Pl3G1YbpSw,122125
40
40
  appier/model.pyi,sha256=Tib26mqYnNAOgsjRaov9T2CmV2pw6IJhdzMYUeN9HM4,1838
41
41
  appier/model_a.py,sha256=c6XpG4oIelXNDK0uicsZ69-f6isUgmh5-29F61PZt9c,16176
42
42
  appier/mongo.py,sha256=t-257ReqFWnEw0bQkDvS4McsPsc6AuKoQXIFHxlrOMw,10891
@@ -58,7 +58,7 @@ appier/smtp.py,sha256=5tW0dOEm03kejLoQyhRQFjgjYRd-jhb-VlhEKDb4Zn0,3434
58
58
  appier/storage.py,sha256=Qp_CMCDg85q35n9lggNVBZRWwlGrQ-nLYNj0W7Mnbec,7470
59
59
  appier/structures.py,sha256=lwAEiz4k1O4bywGcfHvOvZJusN-lUwcviihR9aZLMtY,8883
60
60
  appier/typesf.py,sha256=XIYRQ2M7ErjvjB0SAu4Rkv3aYUOmWhqfZy3sUYyHtpM,37451
61
- appier/util.py,sha256=e2682yvqkx8ck6p1RsgoBcCwPHw-QgVfzzTZRYXEBU8,86801
61
+ appier/util.py,sha256=7K_r30q-Qf1PmtrW5Vhnpm9U1sriRYnWYdQRqCeEFdo,86887
62
62
  appier/validation.py,sha256=vxb289skd7RfGEQVmpkQxYb71JdAfLu17QaKOuAAEEQ,22388
63
63
  appier/res/static/css/base.css,sha256=J9zLozd57KoslAsrsj2a42glGTObxbkrrckR-W-_f2A,6127
64
64
  appier/res/static/images/favicon.ico,sha256=fAL8DLx_0Yl6jwpRG_K6S7g3yXxr9Hyjn3JmqyU8t7U,1150
@@ -67,15 +67,17 @@ appier/res/templates/error.html.tpl,sha256=CiKD-gCC1Zed0zfPFEo6a8qqrEz8Ye9LT-L45
67
67
  appier/res/templates/holder.html.tpl,sha256=lV-z0796VhGcowE9rG9MziHbu2S4H1uxfPmqsbx3ddA,1076
68
68
  appier/res/templates/layout.html.tpl,sha256=e6CVkHTtF8zlFClKFBVWJgMZQ1paHi_240pXahH73BY,2183
69
69
  appier/test/__init__.py,sha256=zMHH-X-dnws-iNXL4JudfPNz1h5oeRSXeS5O5TjoyZk,990
70
- appier/test/base.py,sha256=dJyWcr8egJkrjw4_p9LkUTi9GsFpL82i3lu0nJGrzcc,14857
70
+ appier/test/base.py,sha256=wVNgryfbHLu8niligtDlVFgpyG4rzFuvdKDIQqm1tHg,14806
71
71
  appier/test/cache.py,sha256=WpbfgdsXfAN9Zwo0MZvATygdl-03yqsDYAWKfn4gQf0,6922
72
72
  appier/test/config.py,sha256=r34Rtzzp5X4AkB7MuwiuRi6KF0zTUpLWphymCz90FBE,3472
73
73
  appier/test/crypt.py,sha256=wXIHJjKZJe9qhKfIeGMz5PvQWYRIQVnwbKW-dwUukAo,2457
74
- appier/test/data.py,sha256=jnoJtaLiTemKsXPtKAxd-KZymtIOS96EkWRvrtbxvTU,1353
74
+ appier/test/data.py,sha256=V34Y5oFakc8R8wwYAVyXE8-gelI0_0xTKbruF-cTP3E,1628
75
+ appier/test/error_handler.py,sha256=eTTroF0T5YYeXvKrYqASMN9RlQBgoh25St2xmzR3yMA,4589
76
+ appier/test/exception_handler.py,sha256=nviy8sGuHD06tTp3MfOGyU9mQ7NKEaq3Rr-q10feew8,4853
75
77
  appier/test/exceptions.py,sha256=y2u8jGgGczc9-UipAgRQBssosbt9FNz-OGiyfS_574E,2252
76
78
  appier/test/export.py,sha256=Ou2G5CPQ-n6ip4MIV1jooIRyp5uq3IMGgmVNBIUQOoY,3119
77
79
  appier/test/graph.py,sha256=CRUTH1UJ_mvOR5n_S9gHFy-x1rkgJIT1eJqaAoWZ5uM,6266
78
- appier/test/http.py,sha256=sKr_woe4Q92ZYIBZarYsn9dGMQn8FyES8FwS-3VvUms,8236
80
+ appier/test/http.py,sha256=kJ2VC4M1B8Da7ycG7DEu0peCVGA6Mc3TGuTG1bb5kXI,9164
79
81
  appier/test/legacy.py,sha256=bPgbRjGr8-l2d9xasr7edpV7CwWjyexLA_bz1MQrsE0,5796
80
82
  appier/test/log.py,sha256=dU9b5pqygUvGUw3emVSwURKHxey6AhOwxLdsVxBzKtE,4026
81
83
  appier/test/mock.py,sha256=u_oaaTFS9blSsJWQd-gFak6HCxBYbTEx8DIGFBF9m9o,3282
@@ -90,10 +92,10 @@ appier/test/session.py,sha256=KdiYLLB5autIEu1sHwOuYJXVd0y6RMPgg0ITBuRTMfA,4419
90
92
  appier/test/smtp.py,sha256=XJNa0ZTmabdrX8MfVMgcqBxabvBfHgIimvozdziP4_E,1826
91
93
  appier/test/structures.py,sha256=MRjUFRlnJi-i7YGWW5y792JbJwicNvOIzVAS220tgeQ,8367
92
94
  appier/test/typesf.py,sha256=KHumQFzx7wPZSCb8_mpIwobhIy2Fh_0XYviwPjXMbKI,9680
93
- appier/test/util.py,sha256=SSHuBAZQ0TcXLDYI0xUvmwId5nndDZb88s_5Y-Hqibw,46884
95
+ appier/test/util.py,sha256=vfnleU3BUaqMs1mrpXjKom3V_zFOzrsjhmQ8sYp1GaQ,46668
94
96
  appier/test/validation.py,sha256=riOCsGKob1P5jnbcB5qGZ45ApimNAVS0byg9v_uUdrk,4952
95
- appier-1.34.5.dist-info/LICENSE,sha256=Pd-b5cKP4n2tFDpdx27qJSIq0d1ok0oEcGTlbtL6QMU,11560
96
- appier-1.34.5.dist-info/METADATA,sha256=CLK5mMM4o0GHPH0jWNYsWHwxazJm8qhb3vZotTUd5Ds,1920
97
- appier-1.34.5.dist-info/WHEEL,sha256=kGT74LWyRUZrL4VgLh6_g12IeVl_9u9ZVhadrgXZUEY,110
98
- appier-1.34.5.dist-info/top_level.txt,sha256=Z2e_Y1ya06a554WwQZkfNRiaaQxqsdaPtBzrck384Lo,7
99
- appier-1.34.5.dist-info/RECORD,,
97
+ appier-1.34.7.dist-info/LICENSE,sha256=Pd-b5cKP4n2tFDpdx27qJSIq0d1ok0oEcGTlbtL6QMU,11560
98
+ appier-1.34.7.dist-info/METADATA,sha256=1K9LBt53P9O7UOcwWfh9X3TezynolwVRHeADzXf-xao,1920
99
+ appier-1.34.7.dist-info/WHEEL,sha256=kGT74LWyRUZrL4VgLh6_g12IeVl_9u9ZVhadrgXZUEY,110
100
+ appier-1.34.7.dist-info/top_level.txt,sha256=Z2e_Y1ya06a554WwQZkfNRiaaQxqsdaPtBzrck384Lo,7
101
+ appier-1.34.7.dist-info/RECORD,,