appier 1.31.4__py2.py3-none-any.whl → 1.32.0__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 +333 -52
- appier/amqp.py +29 -30
- appier/api.py +214 -212
- appier/asgi.py +54 -55
- appier/async_neo.py +46 -35
- appier/async_old.py +55 -42
- appier/asynchronous.py +7 -13
- appier/base.py +1762 -1429
- appier/bus.py +51 -52
- appier/cache.py +99 -84
- appier/common.py +9 -11
- appier/component.py +17 -19
- appier/compress.py +25 -28
- appier/config.py +96 -73
- appier/controller.py +9 -15
- appier/crypt.py +25 -21
- appier/data.py +73 -57
- appier/defines.py +191 -226
- appier/exceptions.py +103 -63
- appier/execution.py +94 -88
- appier/export.py +90 -88
- appier/extra.py +6 -13
- appier/extra_neo.py +8 -11
- appier/extra_old.py +18 -16
- appier/geo.py +57 -47
- appier/git.py +101 -90
- appier/graph.py +23 -24
- appier/http.py +520 -398
- appier/legacy.py +373 -180
- appier/log.py +90 -97
- appier/meta.py +42 -42
- appier/mock.py +32 -34
- appier/model.py +793 -681
- appier/model_a.py +208 -183
- appier/mongo.py +183 -107
- appier/observer.py +39 -31
- appier/part.py +23 -24
- appier/preferences.py +44 -47
- appier/queuing.py +78 -96
- appier/redisdb.py +40 -35
- appier/request.py +227 -175
- appier/scheduler.py +13 -18
- appier/serialize.py +37 -31
- appier/session.py +161 -147
- appier/settings.py +2 -11
- appier/smtp.py +53 -49
- appier/storage.py +39 -33
- appier/structures.py +50 -45
- appier/test/__init__.py +2 -11
- appier/test/base.py +111 -108
- appier/test/cache.py +28 -35
- appier/test/config.py +10 -19
- appier/test/crypt.py +3 -12
- appier/test/data.py +3 -12
- appier/test/exceptions.py +8 -17
- appier/test/export.py +16 -33
- appier/test/graph.py +27 -60
- appier/test/http.py +42 -54
- appier/test/legacy.py +20 -30
- appier/test/log.py +14 -35
- appier/test/mock.py +27 -123
- appier/test/model.py +79 -91
- appier/test/part.py +5 -14
- appier/test/preferences.py +5 -13
- appier/test/queuing.py +29 -37
- appier/test/request.py +61 -73
- appier/test/serialize.py +12 -23
- appier/test/session.py +10 -19
- appier/test/smtp.py +8 -14
- appier/test/structures.py +20 -24
- appier/test/typesf.py +14 -28
- appier/test/util.py +480 -438
- appier/typesf.py +251 -171
- appier/util.py +578 -407
- appier/validation.py +280 -143
- {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/METADATA +6 -1
- appier-1.32.0.dist-info/RECORD +86 -0
- appier-1.31.4.dist-info/RECORD +0 -86
- {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/LICENSE +0 -0
- {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/WHEEL +0 -0
- {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/top_level.txt +0 -0
appier/test/structures.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
4
|
# Hive Appier Framework
|
|
5
|
-
# Copyright (c) 2008-
|
|
5
|
+
# Copyright (c) 2008-2024 Hive Solutions Lda.
|
|
6
6
|
#
|
|
7
7
|
# This file is part of Hive Appier Framework.
|
|
8
8
|
#
|
|
@@ -22,16 +22,7 @@
|
|
|
22
22
|
__author__ = "João Magalhães <joamag@hive.pt>"
|
|
23
23
|
""" The author(s) of the module """
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
""" The version of the module """
|
|
27
|
-
|
|
28
|
-
__revision__ = "$LastChangedRevision$"
|
|
29
|
-
""" The revision number of the module """
|
|
30
|
-
|
|
31
|
-
__date__ = "$LastChangedDate$"
|
|
32
|
-
""" The last change date of the module """
|
|
33
|
-
|
|
34
|
-
__copyright__ = "Copyright (c) 2008-2022 Hive Solutions Lda."
|
|
25
|
+
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
|
|
35
26
|
""" The copyright for the module """
|
|
36
27
|
|
|
37
28
|
__license__ = "Apache License, Version 2.0"
|
|
@@ -41,8 +32,8 @@ import unittest
|
|
|
41
32
|
|
|
42
33
|
import appier
|
|
43
34
|
|
|
44
|
-
class OrderedDictTest(unittest.TestCase):
|
|
45
35
|
|
|
36
|
+
class OrderedDictTest(unittest.TestCase):
|
|
46
37
|
def test_basic(self):
|
|
47
38
|
struct = appier.OrderedDict()
|
|
48
39
|
|
|
@@ -68,7 +59,7 @@ class OrderedDictTest(unittest.TestCase):
|
|
|
68
59
|
self.assertEqual(next(iterator), ["third", 3])
|
|
69
60
|
|
|
70
61
|
def test_build(self):
|
|
71
|
-
base = dict(first
|
|
62
|
+
base = dict(first=1, second=2, third=3)
|
|
72
63
|
|
|
73
64
|
struct = appier.OrderedDict(base)
|
|
74
65
|
|
|
@@ -176,42 +167,45 @@ class OrderedDictTest(unittest.TestCase):
|
|
|
176
167
|
self.assertEqual(repr(struct), "[['first', 1], ['second', 2], ['third', 3]]")
|
|
177
168
|
self.assertEqual(str(struct), "[['first', 1], ['second', 2], ['third', 3]]")
|
|
178
169
|
|
|
179
|
-
class LazyDictTest(unittest.TestCase):
|
|
180
170
|
|
|
171
|
+
class LazyDictTest(unittest.TestCase):
|
|
181
172
|
def test_lazy(self):
|
|
182
173
|
struct = appier.LazyDict()
|
|
183
174
|
|
|
184
175
|
struct["first"] = appier.LazyValue(lambda: 2)
|
|
185
176
|
|
|
186
|
-
self.assertEqual(
|
|
177
|
+
self.assertEqual(
|
|
178
|
+
isinstance(struct.__getitem__("first", True), appier.LazyValue), True
|
|
179
|
+
)
|
|
187
180
|
self.assertEqual(struct["first"], 2)
|
|
188
181
|
|
|
189
182
|
def test_resolve(self):
|
|
190
183
|
struct = appier.LazyDict(
|
|
191
|
-
first
|
|
192
|
-
second = appier.LazyValue(lambda: 2)
|
|
184
|
+
first=appier.LazyValue(lambda: 1), second=appier.LazyValue(lambda: 2)
|
|
193
185
|
)
|
|
194
186
|
|
|
195
|
-
resolved = struct.resolve(force
|
|
187
|
+
resolved = struct.resolve(force=True)
|
|
196
188
|
|
|
197
189
|
self.assertNotEqual(type(struct) == dict, True)
|
|
198
|
-
self.assertNotEqual(struct, dict(first
|
|
190
|
+
self.assertNotEqual(struct, dict(first=1, second=2))
|
|
199
191
|
self.assertEqual(type(resolved) == dict, True)
|
|
200
|
-
self.assertEqual(resolved, dict(first
|
|
192
|
+
self.assertEqual(resolved, dict(first=1, second=2))
|
|
201
193
|
|
|
202
194
|
resolved = struct.to_dict()
|
|
203
195
|
|
|
204
196
|
self.assertNotEqual(type(struct) == dict, True)
|
|
205
|
-
self.assertNotEqual(struct, dict(first
|
|
197
|
+
self.assertNotEqual(struct, dict(first=1, second=2))
|
|
206
198
|
self.assertEqual(type(resolved) == dict, True)
|
|
207
|
-
self.assertEqual(resolved, dict(first
|
|
199
|
+
self.assertEqual(resolved, dict(first=1, second=2))
|
|
208
200
|
|
|
209
201
|
def test_naming(self):
|
|
210
202
|
struct = appier.lazy_dict()
|
|
211
203
|
|
|
212
204
|
struct["first"] = appier.lazy(lambda: 1)
|
|
213
205
|
|
|
214
|
-
self.assertEqual(
|
|
206
|
+
self.assertEqual(
|
|
207
|
+
isinstance(struct.__getitem__("first", True), appier.lazy), True
|
|
208
|
+
)
|
|
215
209
|
self.assertEqual(struct["first"], 1)
|
|
216
210
|
|
|
217
211
|
def test_concrete(self):
|
|
@@ -220,7 +214,9 @@ class LazyDictTest(unittest.TestCase):
|
|
|
220
214
|
struct["first"] = appier.lazy(lambda: 1)
|
|
221
215
|
struct["second"] = 2
|
|
222
216
|
|
|
223
|
-
self.assertEqual(
|
|
217
|
+
self.assertEqual(
|
|
218
|
+
isinstance(struct.__getitem__("first", True), appier.lazy), True
|
|
219
|
+
)
|
|
224
220
|
self.assertEqual(struct["first"], 1)
|
|
225
221
|
self.assertEqual(isinstance(struct.__getitem__("second", True), int), True)
|
|
226
222
|
self.assertEqual(struct["second"], 2)
|
appier/test/typesf.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
4
|
# Hive Appier Framework
|
|
5
|
-
# Copyright (c) 2008-
|
|
5
|
+
# Copyright (c) 2008-2024 Hive Solutions Lda.
|
|
6
6
|
#
|
|
7
7
|
# This file is part of Hive Appier Framework.
|
|
8
8
|
#
|
|
@@ -22,16 +22,7 @@
|
|
|
22
22
|
__author__ = "João Magalhães <joamag@hive.pt>"
|
|
23
23
|
""" The author(s) of the module """
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
""" The version of the module """
|
|
27
|
-
|
|
28
|
-
__revision__ = "$LastChangedRevision$"
|
|
29
|
-
""" The revision number of the module """
|
|
30
|
-
|
|
31
|
-
__date__ = "$LastChangedDate$"
|
|
32
|
-
""" The last change date of the module """
|
|
33
|
-
|
|
34
|
-
__copyright__ = "Copyright (c) 2008-2022 Hive Solutions Lda."
|
|
25
|
+
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
|
|
35
26
|
""" The copyright for the module """
|
|
36
27
|
|
|
37
28
|
__license__ = "Apache License, Version 2.0"
|
|
@@ -45,8 +36,8 @@ import appier
|
|
|
45
36
|
|
|
46
37
|
from . import mock
|
|
47
38
|
|
|
48
|
-
class TypesfTest(unittest.TestCase):
|
|
49
39
|
|
|
40
|
+
class TypesfTest(unittest.TestCase):
|
|
50
41
|
def setUp(self):
|
|
51
42
|
self.app = appier.App()
|
|
52
43
|
self.app._register_models_m(mock, "Mocks")
|
|
@@ -118,9 +109,9 @@ class TypesfTest(unittest.TestCase):
|
|
|
118
109
|
person.name = "Name"
|
|
119
110
|
person.cats = mock.Person.cats["type"]([1, 2, 3])
|
|
120
111
|
|
|
121
|
-
self.assertEqual(mock.Cat(identifier
|
|
122
|
-
self.assertEqual(mock.Cat(identifier
|
|
123
|
-
self.assertNotEqual(mock.Cat(identifier
|
|
112
|
+
self.assertEqual(mock.Cat(identifier=1) in person.cats, True)
|
|
113
|
+
self.assertEqual(mock.Cat(identifier=3) in person.cats, True)
|
|
114
|
+
self.assertNotEqual(mock.Cat(identifier=4) in person.cats, True)
|
|
124
115
|
self.assertNotEqual(person.cats, None)
|
|
125
116
|
self.assertNotEqual(person.cats, [])
|
|
126
117
|
self.assertNotEqual(person.cats, "cars")
|
|
@@ -128,7 +119,7 @@ class TypesfTest(unittest.TestCase):
|
|
|
128
119
|
self.assertEqual(len(person.cats), 3)
|
|
129
120
|
|
|
130
121
|
def test_file(self):
|
|
131
|
-
file_m = dict(name
|
|
122
|
+
file_m = dict(name="hello", data=b"SGVsbG8gV29ybGQ=")
|
|
132
123
|
file = appier.File(file_m)
|
|
133
124
|
|
|
134
125
|
self.assertEqual(type(file.file_name), str)
|
|
@@ -149,7 +140,7 @@ class TypesfTest(unittest.TestCase):
|
|
|
149
140
|
self.assertEqual(file.data_b64, "SGVsbG8gV29ybGQ=")
|
|
150
141
|
|
|
151
142
|
def test_encrypted(self):
|
|
152
|
-
encrypted = appier.encrypted(key
|
|
143
|
+
encrypted = appier.encrypted(key=b"hello key")
|
|
153
144
|
result = encrypted("hello world")
|
|
154
145
|
|
|
155
146
|
self.assertEqual(str(result), "hello world")
|
|
@@ -162,7 +153,7 @@ class TypesfTest(unittest.TestCase):
|
|
|
162
153
|
self.assertEqual(result.value, "hello world")
|
|
163
154
|
self.assertEqual(result.encrypted, "vGgMtFgyMVwH3uE=:encrypted")
|
|
164
155
|
|
|
165
|
-
encrypted = appier.encrypted(key
|
|
156
|
+
encrypted = appier.encrypted(key=None)
|
|
166
157
|
result = encrypted("hello world")
|
|
167
158
|
|
|
168
159
|
self.assertEqual(str(result), "hello world")
|
|
@@ -197,7 +188,7 @@ class TypesfTest(unittest.TestCase):
|
|
|
197
188
|
person.brother = brother
|
|
198
189
|
person.save()
|
|
199
190
|
|
|
200
|
-
person = mock.Person.get(identifier
|
|
191
|
+
person = mock.Person.get(identifier=1)
|
|
201
192
|
|
|
202
193
|
result = person.json_v()
|
|
203
194
|
|
|
@@ -220,9 +211,7 @@ class TypesfTest(unittest.TestCase):
|
|
|
220
211
|
self.assertEqual(result, 3)
|
|
221
212
|
|
|
222
213
|
def test_custom(self):
|
|
223
|
-
|
|
224
214
|
class DateTime(appier.Type):
|
|
225
|
-
|
|
226
215
|
def loads(self, value):
|
|
227
216
|
cls = self.__class__
|
|
228
217
|
if isinstance(value, cls):
|
|
@@ -241,10 +230,7 @@ class TypesfTest(unittest.TestCase):
|
|
|
241
230
|
return calendar.timegm(self._datetime.utctimetuple())
|
|
242
231
|
|
|
243
232
|
class CustomPerson(mock.Person):
|
|
244
|
-
|
|
245
|
-
birth = appier.field(
|
|
246
|
-
type = DateTime
|
|
247
|
-
)
|
|
233
|
+
birth = appier.field(type=DateTime)
|
|
248
234
|
|
|
249
235
|
self.app._register_model(CustomPerson)
|
|
250
236
|
|
|
@@ -257,20 +243,20 @@ class TypesfTest(unittest.TestCase):
|
|
|
257
243
|
self.assertEqual(type(person.birth), DateTime)
|
|
258
244
|
self.assertEqual(person.birth.timestamp(), 0)
|
|
259
245
|
|
|
260
|
-
person = CustomPerson.get(name
|
|
246
|
+
person = CustomPerson.get(name="Name")
|
|
261
247
|
|
|
262
248
|
self.assertEqual(person.name, "Name")
|
|
263
249
|
self.assertEqual(type(person.birth), DateTime)
|
|
264
250
|
self.assertEqual(person.birth.timestamp(), 0)
|
|
265
251
|
|
|
266
|
-
person = CustomPerson(name
|
|
252
|
+
person = CustomPerson(name="New Name", birth=1)
|
|
267
253
|
person.save()
|
|
268
254
|
|
|
269
255
|
self.assertEqual(person.name, "New Name")
|
|
270
256
|
self.assertEqual(type(person.birth), DateTime)
|
|
271
257
|
self.assertEqual(person.birth.timestamp(), 1)
|
|
272
258
|
|
|
273
|
-
person = CustomPerson.get(birth
|
|
259
|
+
person = CustomPerson.get(birth=1)
|
|
274
260
|
|
|
275
261
|
self.assertEqual(person.name, "New Name")
|
|
276
262
|
self.assertEqual(type(person.birth), DateTime)
|