aws-python-helper 1.15.3__tar.gz → 1.16.1__tar.gz
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.
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/PKG-INFO +1 -1
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/context/state_validator.py +20 -4
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/repository/base.py +60 -15
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper.egg-info/PKG-INFO +1 -1
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper.egg-info/SOURCES.txt +3 -1
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/pyproject.toml +1 -1
- aws_python_helper-1.16.1/tests/test_effective_statuses.py +90 -0
- aws_python_helper-1.16.1/tests/test_state_validator.py +96 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/README.md +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/api/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/api/auth_middleware.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/api/auth_validators.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/api/base.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/api/dispatcher.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/api/exceptions.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/api/fetcher.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/api/handler.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/api/jwt_keys.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/context/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/context/session.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/database/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/database/database_proxy.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/database/external_database_proxy.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/database/external_mongo_manager.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/database/mongo_manager.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/fargate/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/fargate/executor.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/fargate/fetcher.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/fargate/handler.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/fargate/task_base.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/invoker/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/invoker/api_client.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/invoker/exceptions.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/invoker/lambda_invoker.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/lambda_standalone/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/lambda_standalone/base.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/lambda_standalone/fetcher.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/lambda_standalone/handler.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/model_index_sync/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/model_index_sync/base.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/model_query/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/model_query/base.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/monitoring/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/monitoring/run.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/permissions/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/permissions/catalog.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/repository/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/repository/audit.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/settings.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/sns/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/sns/publisher.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/sqs/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/sqs/consumer_base.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/sqs/fetcher.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/sqs/handler.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/utils/__init__.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/utils/json_encoder.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/utils/response.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/utils/serializer.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper.egg-info/dependency_links.txt +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper.egg-info/requires.txt +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper.egg-info/top_level.txt +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/setup.cfg +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/tests/test_audit_stamp.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/tests/test_json_encoder.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/tests/test_jwt_keys.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/tests/test_model_query_schema.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/tests/test_settings.py +0 -0
- {aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/tests/test_sns_publisher.py +0 -0
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/context/state_validator.py
RENAMED
|
@@ -17,13 +17,21 @@ class StateValidator:
|
|
|
17
17
|
dropped once no service reads it, without a flag day.
|
|
18
18
|
|
|
19
19
|
Uses an in-memory cache with a 5-minute TTL to avoid querying the database
|
|
20
|
-
on every request.
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
on every request. A rejection is cached too, for far less time: the point of
|
|
21
|
+
not caching it was that a state activated a minute ago should start working
|
|
22
|
+
at once, and thirty seconds keeps that while taking the database out of the
|
|
23
|
+
path. It used to be the other way around — only valid states were cached, so
|
|
24
|
+
the most common rejection, a panel pointed at a state where this service is
|
|
25
|
+
not active, queried core.states on *every* request, and every card on a
|
|
26
|
+
screen paid for it. The slowest path was the one taken most.
|
|
23
27
|
"""
|
|
24
28
|
|
|
25
29
|
_cache: Dict[str, float] = {} # state -> timestamp when cached
|
|
30
|
+
_rejected: Dict[str, float] = {} # state -> timestamp when rejected
|
|
26
31
|
_CACHE_TTL: int = 300 # 5 minutes
|
|
32
|
+
# Lo que se le perdona a un rechazo. Corto a propósito: es el techo de lo que
|
|
33
|
+
# un estado recién activado puede tardar en empezar a andar.
|
|
34
|
+
_REJECT_TTL: int = 30
|
|
27
35
|
|
|
28
36
|
@classmethod
|
|
29
37
|
async def validate(cls, state: str):
|
|
@@ -43,6 +51,11 @@ class StateValidator:
|
|
|
43
51
|
return
|
|
44
52
|
del cls._cache[state]
|
|
45
53
|
|
|
54
|
+
if state in cls._rejected:
|
|
55
|
+
if now - cls._rejected[state] < cls._REJECT_TTL:
|
|
56
|
+
raise InvalidStateError(f"State '{state}' is not valid or not active")
|
|
57
|
+
del cls._rejected[state]
|
|
58
|
+
|
|
46
59
|
from ..database.mongo_manager import MongoManager
|
|
47
60
|
db = MongoManager.get_database('core')
|
|
48
61
|
doc = await db.states.find_one({
|
|
@@ -52,11 +65,14 @@ class StateValidator:
|
|
|
52
65
|
|
|
53
66
|
if doc:
|
|
54
67
|
cls._cache[state] = now
|
|
68
|
+
cls._rejected.pop(state, None)
|
|
55
69
|
return
|
|
56
70
|
|
|
71
|
+
cls._rejected[state] = now
|
|
57
72
|
raise InvalidStateError(f"State '{state}' is not valid or not active")
|
|
58
73
|
|
|
59
74
|
@classmethod
|
|
60
75
|
def clear_cache(cls):
|
|
61
|
-
"""Clear the state validation cache."""
|
|
76
|
+
"""Clear the state validation cache, both what passed and what did not."""
|
|
62
77
|
cls._cache.clear()
|
|
78
|
+
cls._rejected.clear()
|
|
@@ -149,26 +149,66 @@ class Repository(ABC):
|
|
|
149
149
|
@property
|
|
150
150
|
def statuses(self) -> Optional[List[str]]:
|
|
151
151
|
"""
|
|
152
|
-
|
|
152
|
+
Los valores que puede tomar el `status` de este registro.
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
show the state of anything without knowing what it is looking at. A
|
|
156
|
-
repository with its own lifecycle declares it:
|
|
154
|
+
Tres formas, según lo que la colección necesite:
|
|
157
155
|
|
|
158
|
-
|
|
156
|
+
**No declarar nada.** Se queda con los dos de siempre, `active` e
|
|
157
|
+
`inactive`, que es lo que hace que un listado pueda mostrar el estado de
|
|
158
|
+
cualquier cosa sin saber qué está mirando.
|
|
159
|
+
|
|
160
|
+
**Declarar `statuses`.** Reemplaza a los default: el vocabulario es ese y
|
|
161
|
+
no hay otro. Para una colección cuyo ciclo es completo y ajeno, donde
|
|
162
|
+
"activo" no significaría nada.
|
|
163
|
+
|
|
164
|
+
class SearchedKeyRepository(Repository):
|
|
159
165
|
@property
|
|
160
166
|
def statuses(self):
|
|
161
|
-
return ["
|
|
167
|
+
return ["queued", "in_progress", "complete", "failed"]
|
|
168
|
+
|
|
169
|
+
**Declarar `extra_statuses`.** Se suman a los default, que siguen
|
|
170
|
+
valiendo. Para una colección que tiene estados propios *además* del
|
|
171
|
+
ciclo de vida del registro.
|
|
172
|
+
|
|
173
|
+
class TaxSaleRepository(Repository):
|
|
174
|
+
@property
|
|
175
|
+
def extra_statuses(self):
|
|
176
|
+
return ["new"] # efectivo: new, active, inactive
|
|
162
177
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
178
|
+
Una escritura con un valor fuera del conjunto efectivo se rechaza, no se
|
|
179
|
+
guarda: un status que nadie esperaba llega a un panel como una etiqueta
|
|
180
|
+
desconocida y a una consulta como un silencio.
|
|
166
181
|
|
|
167
|
-
None
|
|
168
|
-
|
|
182
|
+
`None` para colecciones donde un ciclo de vida no significa nada
|
|
183
|
+
—sesiones, tokens, contadores—.
|
|
169
184
|
"""
|
|
170
185
|
return list(DEFAULT_STATUSES)
|
|
171
186
|
|
|
187
|
+
@property
|
|
188
|
+
def extra_statuses(self) -> Optional[List[str]]:
|
|
189
|
+
"""Valores propios que se agregan a los declarados, sin quitarlos.
|
|
190
|
+
|
|
191
|
+
La diferencia con `statuses` es qué pasa con `active` e `inactive`: acá
|
|
192
|
+
siguen valiendo. Ver la nota en `statuses`.
|
|
193
|
+
"""
|
|
194
|
+
return None
|
|
195
|
+
|
|
196
|
+
@property
|
|
197
|
+
def effective_statuses(self) -> Optional[List[str]]:
|
|
198
|
+
"""Lo que de verdad se acepta, ya resueltas las dos declaraciones.
|
|
199
|
+
|
|
200
|
+
Los extra van primero y sin repetir, porque el primero del conjunto es
|
|
201
|
+
el que recibe un registro nuevo cuando nadie dice otra cosa.
|
|
202
|
+
"""
|
|
203
|
+
declared = self.statuses
|
|
204
|
+
extra = self.extra_statuses
|
|
205
|
+
|
|
206
|
+
if declared is None:
|
|
207
|
+
return list(dict.fromkeys(extra)) if extra else None
|
|
208
|
+
if not extra:
|
|
209
|
+
return list(declared)
|
|
210
|
+
return list(dict.fromkeys(list(extra) + list(declared)))
|
|
211
|
+
|
|
172
212
|
@property
|
|
173
213
|
def status_field(self) -> str:
|
|
174
214
|
"""Cómo se llama el campo que lleva el ciclo de vida del registro.
|
|
@@ -191,9 +231,14 @@ class Repository(ABC):
|
|
|
191
231
|
|
|
192
232
|
@property
|
|
193
233
|
def default_status(self) -> Optional[str]:
|
|
194
|
-
"""
|
|
195
|
-
|
|
196
|
-
|
|
234
|
+
"""Con qué nace un registro cuando nadie dice otra cosa.
|
|
235
|
+
|
|
236
|
+
El primero del conjunto efectivo, que con `extra_statuses` es el primero
|
|
237
|
+
de los propios: una venta nace `new`, no `active`, aunque `active`
|
|
238
|
+
también valga.
|
|
239
|
+
"""
|
|
240
|
+
effective = self.effective_statuses
|
|
241
|
+
return effective[0] if effective else None
|
|
197
242
|
|
|
198
243
|
@property
|
|
199
244
|
def audit(self) -> bool:
|
|
@@ -277,7 +322,7 @@ class Repository(ABC):
|
|
|
277
322
|
# La envoltura completa las escrituras; todo lo demás pasa de largo.
|
|
278
323
|
self._collection_cache[key] = (
|
|
279
324
|
AuditedCollection(
|
|
280
|
-
collection, self.
|
|
325
|
+
collection, self.effective_statuses, self.default_status, self.status_field
|
|
281
326
|
)
|
|
282
327
|
if self.audit
|
|
283
328
|
else collection
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper.egg-info/SOURCES.txt
RENAMED
|
@@ -59,8 +59,10 @@ aws_python_helper/utils/json_encoder.py
|
|
|
59
59
|
aws_python_helper/utils/response.py
|
|
60
60
|
aws_python_helper/utils/serializer.py
|
|
61
61
|
tests/test_audit_stamp.py
|
|
62
|
+
tests/test_effective_statuses.py
|
|
62
63
|
tests/test_json_encoder.py
|
|
63
64
|
tests/test_jwt_keys.py
|
|
64
65
|
tests/test_model_query_schema.py
|
|
65
66
|
tests/test_settings.py
|
|
66
|
-
tests/test_sns_publisher.py
|
|
67
|
+
tests/test_sns_publisher.py
|
|
68
|
+
tests/test_state_validator.py
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""Las tres formas de declarar el vocabulario de `status`."""
|
|
2
|
+
|
|
3
|
+
from aws_python_helper.repository.audit import DEFAULT_STATUSES
|
|
4
|
+
from aws_python_helper.repository.base import Repository
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class SinDeclarar(Repository):
|
|
8
|
+
"""Se queda con los dos de siempre."""
|
|
9
|
+
|
|
10
|
+
@property
|
|
11
|
+
def collection_name(self):
|
|
12
|
+
return "sin"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class CicloPropio(Repository):
|
|
16
|
+
"""Reemplaza: `active` no significaría nada para una búsqueda."""
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def collection_name(self):
|
|
20
|
+
return "busquedas"
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def statuses(self):
|
|
24
|
+
return ["queued", "in_progress", "complete", "failed"]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class CicloExtra(Repository):
|
|
28
|
+
"""Suma: una venta nace `new` y además puede darse de baja."""
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def collection_name(self):
|
|
32
|
+
return "ventas"
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def extra_statuses(self):
|
|
36
|
+
return ["new"]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class SinCiclo(Repository):
|
|
40
|
+
"""Una colección donde un ciclo de vida no significa nada."""
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def collection_name(self):
|
|
44
|
+
return "tokens"
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def statuses(self):
|
|
48
|
+
return None
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class ExtraRepetido(Repository):
|
|
52
|
+
"""Agrega uno que ya estaba: no se duplica."""
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def collection_name(self):
|
|
56
|
+
return "repetido"
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def extra_statuses(self):
|
|
60
|
+
return ["new", "active"]
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def test_sin_declarar_quedan_los_default():
|
|
64
|
+
assert SinDeclarar().effective_statuses == list(DEFAULT_STATUSES)
|
|
65
|
+
assert SinDeclarar().default_status == "active"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_statuses_reemplaza_a_los_default():
|
|
69
|
+
assert CicloPropio().effective_statuses == [
|
|
70
|
+
"queued", "in_progress", "complete", "failed",
|
|
71
|
+
]
|
|
72
|
+
assert "active" not in CicloPropio().effective_statuses
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_extra_se_suma_a_los_default():
|
|
76
|
+
assert CicloExtra().effective_statuses == ["new", "active", "inactive"]
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_el_primero_es_con_el_que_nace():
|
|
80
|
+
assert CicloPropio().default_status == "queued"
|
|
81
|
+
assert CicloExtra().default_status == "new"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_sin_ciclo_no_valida_nada():
|
|
85
|
+
assert SinCiclo().effective_statuses is None
|
|
86
|
+
assert SinCiclo().default_status is None
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def test_un_extra_que_ya_era_default_no_se_repite():
|
|
90
|
+
assert ExtraRepetido().effective_statuses == ["new", "active", "inactive"]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""El caché del validador de estado, con la base falseada.
|
|
2
|
+
|
|
3
|
+
Se falsea `MongoManager`, no el validador: lo que se quiere comprobar es cuántas
|
|
4
|
+
veces pregunta y cuándo vuelve a preguntar.
|
|
5
|
+
|
|
6
|
+
Correr con un intérprete que tenga las dependencias del paquete:
|
|
7
|
+
../constitution-core/venv/bin/python tests/test_state_validator.py
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import asyncio
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
from aws_python_helper.context.state_validator import InvalidStateError, StateValidator
|
|
14
|
+
import aws_python_helper.database.mongo_manager as mongo_manager
|
|
15
|
+
|
|
16
|
+
consultas = {"n": 0}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class FakeStates:
|
|
20
|
+
async def find_one(self, query):
|
|
21
|
+
consultas["n"] += 1
|
|
22
|
+
return {"name": query["name"]} if query["name"] == "connecticut" else None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class FakeDB:
|
|
26
|
+
states = FakeStates()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
mongo_manager.MongoManager.get_database = staticmethod(lambda name: FakeDB())
|
|
30
|
+
|
|
31
|
+
fallos = []
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def igual(que, a, b):
|
|
35
|
+
ok = a == b
|
|
36
|
+
print((" ok " if ok else " FALLA ") + que + ("" if ok else f" -> {a!r} != {b!r}"))
|
|
37
|
+
if not ok:
|
|
38
|
+
fallos.append(que)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
async def main():
|
|
42
|
+
print("StateValidator")
|
|
43
|
+
|
|
44
|
+
StateValidator.clear_cache()
|
|
45
|
+
consultas["n"] = 0
|
|
46
|
+
for _ in range(5):
|
|
47
|
+
await StateValidator.validate("connecticut")
|
|
48
|
+
igual("un estado activo se pregunta una sola vez", consultas["n"], 1)
|
|
49
|
+
|
|
50
|
+
# Lo que antes pegaba en la base en cada request: el rechazo no se cacheaba,
|
|
51
|
+
# y es el caso más común —el panel parado en un estado donde el servicio no
|
|
52
|
+
# está activo—, así que cada tarjeta de la pantalla lo pagaba.
|
|
53
|
+
StateValidator.clear_cache()
|
|
54
|
+
consultas["n"] = 0
|
|
55
|
+
rechazos = 0
|
|
56
|
+
for _ in range(5):
|
|
57
|
+
try:
|
|
58
|
+
await StateValidator.validate("new_jersey")
|
|
59
|
+
except InvalidStateError:
|
|
60
|
+
rechazos += 1
|
|
61
|
+
igual("un estado inactivo tambien se pregunta una sola vez", consultas["n"], 1)
|
|
62
|
+
igual("y sigue devolviendo el error en todos", rechazos, 5)
|
|
63
|
+
|
|
64
|
+
# Que se cachee no puede volverlo permanente: un estado recién activado
|
|
65
|
+
# tiene que empezar a andar, y el techo de esa espera es el TTL del rechazo.
|
|
66
|
+
previo = StateValidator._REJECT_TTL
|
|
67
|
+
try:
|
|
68
|
+
StateValidator._REJECT_TTL = 0
|
|
69
|
+
consultas["n"] = 0
|
|
70
|
+
try:
|
|
71
|
+
await StateValidator.validate("new_jersey")
|
|
72
|
+
except InvalidStateError:
|
|
73
|
+
pass
|
|
74
|
+
igual("vencido el TTL del rechazo, vuelve a preguntar", consultas["n"], 1)
|
|
75
|
+
finally:
|
|
76
|
+
StateValidator._REJECT_TTL = previo
|
|
77
|
+
|
|
78
|
+
# Un estado que pasa a activo deja de estar rechazado, sin esperar al TTL.
|
|
79
|
+
StateValidator.clear_cache()
|
|
80
|
+
consultas["n"] = 0
|
|
81
|
+
try:
|
|
82
|
+
await StateValidator.validate("new_jersey")
|
|
83
|
+
except InvalidStateError:
|
|
84
|
+
pass
|
|
85
|
+
await StateValidator.validate("connecticut")
|
|
86
|
+
igual("el rechazo de uno no tapa al otro", consultas["n"], 2)
|
|
87
|
+
|
|
88
|
+
StateValidator.clear_cache()
|
|
89
|
+
igual("clear_cache limpia los dos",
|
|
90
|
+
(StateValidator._cache, StateValidator._rejected), ({}, {}))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
asyncio.run(main())
|
|
94
|
+
print()
|
|
95
|
+
print(f"{len(fallos)} FALLARON: {fallos}" if fallos else "todo en orden")
|
|
96
|
+
sys.exit(1 if fallos else 0)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/api/auth_middleware.py
RENAMED
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/api/auth_validators.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/database/__init__.py
RENAMED
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/database/database_proxy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/database/mongo_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/fargate/task_base.py
RENAMED
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/invoker/api_client.py
RENAMED
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/invoker/exceptions.py
RENAMED
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/invoker/lambda_invoker.py
RENAMED
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/lambda_standalone/base.py
RENAMED
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/lambda_standalone/fetcher.py
RENAMED
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/lambda_standalone/handler.py
RENAMED
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/model_index_sync/__init__.py
RENAMED
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/model_index_sync/base.py
RENAMED
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/model_query/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/monitoring/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/permissions/__init__.py
RENAMED
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/permissions/catalog.py
RENAMED
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/repository/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/sqs/consumer_base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper/utils/json_encoder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper.egg-info/requires.txt
RENAMED
|
File without changes
|
{aws_python_helper-1.15.3 → aws_python_helper-1.16.1}/aws_python_helper.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|