vortexpy 6.1.1__tar.gz → 6.1.2__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.
- {vortexpy-6.1.1 → vortexpy-6.1.2}/PKG-INFO +1 -1
- {vortexpy-6.1.1 → vortexpy-6.1.2}/pyproject.toml +1 -1
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/Tuple.py +25 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/TupleBson.py +7 -25
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/TupleBson_test.py +27 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/__init__.py +1 -1
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortexpy.egg-info/PKG-INFO +1 -1
- {vortexpy-6.1.1 → vortexpy-6.1.2}/README.md +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/example/TwistedDeferredTimeout.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/example/__init__.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/example/run_http_upgraded_websocket_ping_client.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/example/run_http_upgraded_websocket_ping_server.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/example/run_http_upgraded_websocket_rpc_test_client.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/example/run_http_upgraded_websocket_rpc_test_server.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/example/run_websocket_rpc_test_client.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/example/run_websocket_rpc_test_server.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/example/setup_example_logging.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/example/store_and_load_json.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/setup.cfg +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/DataWrapTuple.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/DeferUtil.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/DeferUtil_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/Jsonable.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/MtlsAuthorizedClientRegistry.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/MtlsAuthorizedClientRegistry_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/MtlsServerSslOptions.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/Payload.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/PayloadEndpoint.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/PayloadEndpointTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/PayloadEnvelope.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/PayloadFilterKeys.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/PayloadIO.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/PayloadPriority.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/PayloadResponse.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/PayloadResponseTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/PayloadResponse_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/PayloadTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/PerformTestActionTuple.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/SerialiseUtil.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/SerialiseUtil_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/TestTuple.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/TupleAction.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/TupleDataForTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/TupleDocumentConverter.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/TuplePerfTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/TuplePolymorphicTupleTypeFieldArgTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/TupleRestful.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/TupleRestful_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/TupleSelector.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/TupleTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexABC.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexAccessControlContextABC.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexAuthenticatorABC.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexClientHttp.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexClientHttpTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexClientTcp.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexClientWebsocketFactory.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexConnectionABC.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexEndpointPermission.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexFactory.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexFactory_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexPayloadProtocol.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexPermission.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexPermissionError.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexServer.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexServerConnection.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexServerConnection_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexServerHttpResource.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexServerTcp.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexServerTcp_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexServerWebsocket.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexServerWebsocket_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexServer_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexSession.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexSession_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexTcpMemoryLeakPayloadTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexTcpMemoryLeakRawTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexUserDetailsABC.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexUtil.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexWritePushProducer.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/VortexWritePushProducer_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/data_loader/TupleDataLiveLockManager.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/data_loader/TupleDataLiveLockManager_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/data_loader/TupleDataLoader.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/data_loader/TupleDataLoaderDelegate.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/data_loader/TupleDataLoaderTupleABC.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/data_loader/TupleDataLoaderTuples.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/data_loader/__init__.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/event_bus/TupleChangeEventABC.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/event_bus/TupleChangeEventBus.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/event_bus/TupleChangeEventBusObserverABC.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/event_bus/__init__.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleActionProcessor.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleActionProcessorProxy.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleActionProcessorTestHandler.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleActionProcessor_shutdown_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleActionProcessor_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleActionPushOffline.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleActionPushOffline_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleDataAccessGranterABC.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleDataActionClient.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleDataActionClient_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleDataObservableCache.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleDataObservableCache_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleDataObservableHandler.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleDataObservableHandler_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleDataObservableProxyHandler.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleDataObservableProxyHandler_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleDataObservableTestHandler.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleDataObserverClient.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/TupleDataProviderABC.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/VortexJSTupleLoaderTestHandler.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/handler/__init__.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/mypy_plugin.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/payload_many_tuples_benchmark_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/py.typed +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/restful/GzippedDataHttpClient.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/restful/GzippedDataHttpClientTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/restful/GzippedPayloadHttpClient.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/restful/RestfulHttpClient.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/restful/RestfulResource.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/restful/__init__.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/restful/restful_http_client_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/restful/restful_resource_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/rpc/RPC.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/rpc/RPCTest.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/rpc/RPC_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/rpc/__init__.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/sqla_orm/OrmCrudHandler.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/sqla_orm/TupleProviderForDb.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/sqla_orm/VortexTupleJson.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/sqla_orm/__init__.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/storage/TupleActionStorageSqlite.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/storage/TupleStorageSqlite.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/storage/__init__.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/tuple_json_schema/__init__.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/tuple_json_schema/constants.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/tuple_json_schema/json_schema_node_tuple.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/tuple_json_schema/tuple_json_schema_builder.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/tuple_json_schema/tuple_json_schema_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/tuple_json_schema/tuple_json_schema_test_tuples.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/tuple_test_fixtures.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/twisted_runtime_metrics.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortex/twisted_runtime_metrics_test.py +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortexpy.egg-info/SOURCES.txt +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortexpy.egg-info/dependency_links.txt +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortexpy.egg-info/entry_points.txt +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortexpy.egg-info/requires.txt +0 -0
- {vortexpy-6.1.1 → vortexpy-6.1.2}/vortexpy.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "vortexpy"
|
|
7
|
-
version = "6.1.
|
|
7
|
+
version = "6.1.2"
|
|
8
8
|
license = {text = "MIT"}
|
|
9
9
|
authors = [{name = "Flying Ion Pty Ltd", email = "contact@flyingion.com"}]
|
|
10
10
|
description = "Flying Ion's observable, routable, data serialisation and transport code."
|
|
@@ -29,6 +29,9 @@ from .SerialiseUtil import ISO8601
|
|
|
29
29
|
from .SerialiseUtil import T_RAPUI_TUPLE
|
|
30
30
|
from .SerialiseUtil import WKBElement
|
|
31
31
|
from .SerialiseUtil import convertFromWkbElement
|
|
32
|
+
from .SerialiseUtil import datetimeToBson
|
|
33
|
+
from .SerialiseUtil import datetimeToBsonMicroseconds
|
|
34
|
+
from .SerialiseUtil import requireAwareDatetime
|
|
32
35
|
|
|
33
36
|
logger = logging.getLogger(__name__)
|
|
34
37
|
|
|
@@ -319,6 +322,28 @@ class TupleField:
|
|
|
319
322
|
self.jsonExclude = jsonExclude
|
|
320
323
|
self.bsonDatetimeFormat = bsonDatetimeFormat
|
|
321
324
|
|
|
325
|
+
def toBson(self, value: Any) -> Any:
|
|
326
|
+
"""Convert a datetime to this field's BSON storage format.
|
|
327
|
+
|
|
328
|
+
Non-datetime values pass through unchanged, so every Mongo
|
|
329
|
+
filter value can be wrapped uniformly. Naive datetimes raise
|
|
330
|
+
``TypeError``.
|
|
331
|
+
"""
|
|
332
|
+
if not isinstance(value, datetime):
|
|
333
|
+
return value
|
|
334
|
+
aware = requireAwareDatetime(value)
|
|
335
|
+
if self.bsonDatetimeFormat is None:
|
|
336
|
+
return datetimeToBson(aware)
|
|
337
|
+
if self.bsonDatetimeFormat is BsonDatetimeFormatE.standardMsIntEpoch:
|
|
338
|
+
return datetimeToBson(aware)
|
|
339
|
+
if self.bsonDatetimeFormat is BsonDatetimeFormatE.standardUsIntEpoch:
|
|
340
|
+
return datetimeToBsonMicroseconds(aware)
|
|
341
|
+
if self.bsonDatetimeFormat is BsonDatetimeFormatE.standardMsBsonDate:
|
|
342
|
+
return aware
|
|
343
|
+
raise NotImplementedError(
|
|
344
|
+
f"Unsupported BsonDatetimeFormatE {self.bsonDatetimeFormat!r}"
|
|
345
|
+
)
|
|
346
|
+
|
|
322
347
|
|
|
323
348
|
class PolymorphicTupleTypeFieldArg:
|
|
324
349
|
def __init__(self, fieldName: str):
|
|
@@ -43,7 +43,6 @@ from .SerialiseUtil import WKBElement
|
|
|
43
43
|
from .SerialiseUtil import convertFromWkbElement
|
|
44
44
|
from .SerialiseUtil import datetimeFromBson
|
|
45
45
|
from .SerialiseUtil import datetimeToBson
|
|
46
|
-
from .SerialiseUtil import datetimeToBsonMicroseconds
|
|
47
46
|
from .SerialiseUtil import requireAwareDatetime
|
|
48
47
|
from .Tuple import BsonDatetimeFormatE
|
|
49
48
|
from .Tuple import TupleField
|
|
@@ -65,24 +64,6 @@ class TupleBsonConverter(TupleDocumentConverterBase):
|
|
|
65
64
|
return tupleField.bsonDatetimeFormat
|
|
66
65
|
return None
|
|
67
66
|
|
|
68
|
-
@classmethod
|
|
69
|
-
def _utilDatetimeToBsonStorageValue(
|
|
70
|
-
cls,
|
|
71
|
-
value: datetime,
|
|
72
|
-
bsonDatetimeFormat: BsonDatetimeFormatE | None,
|
|
73
|
-
) -> datetime | int:
|
|
74
|
-
if bsonDatetimeFormat is None:
|
|
75
|
-
return datetimeToBson(value)
|
|
76
|
-
if bsonDatetimeFormat is BsonDatetimeFormatE.standardMsIntEpoch:
|
|
77
|
-
return datetimeToBson(value)
|
|
78
|
-
if bsonDatetimeFormat is BsonDatetimeFormatE.standardUsIntEpoch:
|
|
79
|
-
return datetimeToBsonMicroseconds(value)
|
|
80
|
-
if bsonDatetimeFormat is BsonDatetimeFormatE.standardMsBsonDate:
|
|
81
|
-
return requireAwareDatetime(value)
|
|
82
|
-
raise NotImplementedError(
|
|
83
|
-
f"Unsupported BsonDatetimeFormatE {bsonDatetimeFormat!r}"
|
|
84
|
-
)
|
|
85
|
-
|
|
86
67
|
@classmethod
|
|
87
68
|
def _utilCoerceIntOrFloatEpochToDatetime(
|
|
88
69
|
cls,
|
|
@@ -145,7 +126,7 @@ class TupleBsonConverter(TupleDocumentConverterBase):
|
|
|
145
126
|
|
|
146
127
|
def convert(
|
|
147
128
|
value: Any,
|
|
148
|
-
|
|
129
|
+
tupleField: TupleField | None = None,
|
|
149
130
|
) -> Any:
|
|
150
131
|
if isinstance(value, list):
|
|
151
132
|
return [convert(item) for item in value]
|
|
@@ -165,17 +146,18 @@ class TupleBsonConverter(TupleDocumentConverterBase):
|
|
|
165
146
|
return None
|
|
166
147
|
|
|
167
148
|
if isinstance(value, datetime):
|
|
168
|
-
|
|
149
|
+
if tupleField is None:
|
|
150
|
+
return datetimeToBson(value)
|
|
151
|
+
return tupleField.toBson(value)
|
|
169
152
|
|
|
170
153
|
return value
|
|
171
154
|
|
|
172
155
|
for shortName, normalName in tuple_.__shortFieldNamesMap__.items():
|
|
173
156
|
tupleField = getattr(type(tuple_), normalName, None)
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
fieldFormat = tupleField.bsonDatetimeFormat
|
|
157
|
+
if not isinstance(tupleField, TupleField):
|
|
158
|
+
tupleField = None
|
|
177
159
|
|
|
178
|
-
value = convert(getattr(tuple_, normalName),
|
|
160
|
+
value = convert(getattr(tuple_, normalName), tupleField)
|
|
179
161
|
if value is None and not includeNones:
|
|
180
162
|
continue
|
|
181
163
|
if value is False and not includeFalse:
|
|
@@ -250,6 +250,33 @@ class TupleBsonTest(unittest.TestCase):
|
|
|
250
250
|
)
|
|
251
251
|
self.assertEqual(deserialisedTuple.at, aware)
|
|
252
252
|
|
|
253
|
+
def testTupleFieldToBsonConvertsDatetimePerFormat(self) -> None:
|
|
254
|
+
aware = datetime(2020, 1, 2, 3, 4, 5, 678000, tzinfo=UTC)
|
|
255
|
+
self.assertEqual(
|
|
256
|
+
BsonDatetimeFormatTestTuple.defaultMsDate.toBson(aware),
|
|
257
|
+
datetimeToBson(aware),
|
|
258
|
+
)
|
|
259
|
+
self.assertEqual(
|
|
260
|
+
BsonDatetimeFormatTestTuple.microsecondDate.toBson(aware),
|
|
261
|
+
datetimeToBsonMicroseconds(aware),
|
|
262
|
+
)
|
|
263
|
+
self.assertEqual(
|
|
264
|
+
BsonDatetimeFormatTestTuple.bsonDateField.toBson(aware),
|
|
265
|
+
aware,
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
def testTupleFieldToBsonPassesThroughNonDatetimeValues(self) -> None:
|
|
269
|
+
field = BsonDatetimeFormatTestTuple.defaultMsDate
|
|
270
|
+
self.assertEqual(field.toBson("2026-10-23"), "2026-10-23")
|
|
271
|
+
self.assertEqual(field.toBson(1577934245678), 1577934245678)
|
|
272
|
+
self.assertIs(field.toBson(True), True)
|
|
273
|
+
self.assertIsNone(field.toBson(None))
|
|
274
|
+
|
|
275
|
+
def testTupleFieldToBsonRejectsNaiveDatetime(self) -> None:
|
|
276
|
+
naive = datetime(2020, 1, 2, 3, 4, 5, 678000)
|
|
277
|
+
with self.assertRaises(TypeError):
|
|
278
|
+
BsonDatetimeFormatTestTuple.defaultMsDate.toBson(naive)
|
|
279
|
+
|
|
253
280
|
|
|
254
281
|
class TupleBsonCollectingTest(unittest.TestCase):
|
|
255
282
|
def testSingleBadScalarCollectsErrorAndPopulatesOtherFields(self) -> None:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|